akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int a[]=new int[N+2];
		int sum=0;
		a[0] = 0;
		for(int i=1;i<=N;i++) {
			a[i] = in.nextInt();
			sum=sum+Math.abs(a[i-1]-a[i]);
		}
		a[N+1]=0;
		sum=sum+Math.abs(a[N]-a[N+1]);
		int tmp1=0;
		int tmp2=0;
		for(int i=1;i<=N;i++) {
			tmp1=Math.abs(a[i-1]-a[i])+Math.abs(a[i]-a[i+1]);
			tmp2=Math.abs(a[i-1]-a[i+1]);
			System.out.println(sum-tmp1+tmp2);
		}

	}
}


Measured memory_bytes: 67980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = k, j = 0; i < n; i++, j++) {
        if(a[i] > a[j]) cout << "Yes\n";
        else cout << "No\n";
    }
}
           

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5224
import math
import sys
MOD = 1000000007

h, w, k = map(int, input().split())

if w == 1:
    print(1)
    sys.exit()

A = [[1]]


def bit(x, i):
    return (x >> i) & 1


def invalid(x):
    ans = False
    for j in range(w):
        if bit(x, j) == 1 and bit(x, j+1) == 1:
            ans = True
    return ans


for i in range(w-1):
    A[0].append(0)

for i in range(1, h+1):
    A.append([])
    for j in range(w):
        A[i].append(0)
    for x in range(2**(w-1)):
        if(invalid(x)):
            continue
        
        # corner case
        if bit(x, 0) == 1:
            A[i][0] = (A[i][0] + A[i-1][1]) % MOD
        else:
            A[i][0] = (A[i][0] + A[i-1][0]) % MOD
        if bit(x, w-2) == 1:
            A[i][w-1] = (A[i][w-1] + A[i-1][w-2]) % MOD
        else:
            A[i][w-1] = (A[i][w-1] + A[i-1][w-1]) % MOD
        
        for j in range(1, w-1):
            if bit(x, j-1) == 1:
                A[i][j] = (A[i][j] + A[i-1][j-1]) % MOD
            elif bit(x, j) == 1:
                A[i][j] = (A[i][j] + A[i-1][j+1]) % MOD
            else:
                A[i][j] = (A[i][j] + A[i-1][j]) % MOD

#print(A)

print(A[h][k-1])


Measured memory_bytes: 44528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    if('A' <= c && c <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int b,c,ans=0,preans=0;
    cin>>b>>c;
    char a[b+1][c+1];
    for(int i=0;i<b;i++){
        a[0][i]=='+';
    }
    for(int i=0;i<c;i++){
        a[i][0]=='+';
    }
    for(int i=1;i<b+1;i++){
        for(int j=1;j<c+1;j++){
            cin>>a[i][j];
            if(a[i][j]=='#'){
                preans++;
            }
        }
    }
    for(int i=1;i<b+1;i++){
        for(int j=1;j<c+1;j++){
            if(a[i][j]!='.' && (a[i-1][j]=='#'||a[i][j-1]=='#'||a[i][j+1]=='#' ||a[i+1][j]=='#') ){
                ans++;
            }        
        }

    }
    if(preans==ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


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

const ll MAX_N = 1e5;

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

    ll n;
    cin >> n;

    vector<ll> cusum(MAX_N);
    
    cusum[0] = 1;
    
    ll i = 2;
    while(true){
        cusum[i-1] = cusum[i-2] + i;
        if(cusum[i] >= n) break;
        i++;
    }

    auto itr = lower_bound(cusum.begin(), cusum.end(), n) - cusum.begin();
    
    ll a = cusum[itr] - n;
    
    for(ll i = 1; i <= itr + 1; i++){
        if(i == a) continue;
        cout << i << endl;
    }
}

 



Measured memory_bytes: 1024
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



int main() {
    string S;
    cin >> S;

    int len_S = S.size();
    for (int i = 1; i < len_S; ++i) {
        int l = (len_S - i) / 2;
        string S1 = S.substr(0, l);
        string S2 = S.substr(l, l);

        if(S1 == S2){
            cout << l*2 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S.size()%2!=0){
        cout<<NO<<endl;
        return;
    }
    rep(i,S.size()){
        if(i%2==0&&S[i]!='h'||i%2==1&&S[i]!='i'){
            cout<<NO<<endl;
            return;
        }
    }
    cout<<YES<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];

        for(int i=0;i<n;i++)
        cin>>a[i];
      sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++)
    sum+=a[i];
  cout<<sum<<"\n";
  return 0;
        }

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer m = Integer.parseInt(scanner.next());
        int total = 0;

        total += (n * (n-1) / 2);
        total += (m * (m-1) / 2);

        System.out.println(total);
    }
}

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

int h[100][100];
int f[100][100];

int main()
{
	int n;
	while(cin >> n, n)
	{
		memset(f,0,sizeof(f));

		for(int y=0; y<n; y++)
		for(int x=0; x<n; x++)
		{
			cin >> h[y][x];
		}

		int val;
		for(int y=0; y<n; y++)
		{
			val = h[y][0];
			for(int x=1; x<n; x++)
			{
				val = min(val,h[y][x]);
			}
			for(int x=0; x<n; x++)
			{
				if(val==h[y][x]) f[y][x]++;
			}
		}

		for(int x=0; x<n; x++)
		{
			val = h[0][x];
			for(int y=1; y<n; y++)
			{
				val = max(val,h[y][x]);
			}
			for(int y=0; y<n; y++)
			{
				if(val==h[y][x]) f[y][x]++;
			}
		}

		int a=0;
		for(int y=0; y<n; y++)
		for(int x=0; x<n; x++)
		{
			if(f[y][x]==2) a=h[y][x];
		}

		cout << a << endl;
	}
}

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


int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for(int i=0;i<h;++i){
    cin >> c[i];
    //cout << "ok" << endl;
  }

  int ans=0;
  for(int hb=0;hb<1<<h;++hb){
    for(int wb=0;wb<1<<w;++wb){
      int cnt=0;
      for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
          if(hb>>i&1) continue;
          if(wb>>j&1) continue;
          if(c[i][j]=='#') cnt++;
        }
      }
      if(cnt==k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    // variable
    double ans = 0;

    // input
    cout << fixed << setprecision(10);
    int N, K; cin >> N >> K;
    vector<double> p(N);
    vector<double> sum(N+1);
    fill(ALL(sum), 0);
    rep(i, N){
        cin >> p[i];
        p[i] = (p[i] * (p[i]+1))/(2 * p[i]);
        sum[i+1] += sum[i] + p[i];
    } 

    // solve
    rep2(i, K, N+1){
        ans = max(ans, sum[i] - sum[i-K]);
    }

    print(ans);
    
    return 0;
}


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

int main()
{
	long long x;
	cin >> x;

	long long i = 100;
	long long ret = 0;
	while (i < x)
	{
		i = i + i / 100;
		++ret;
	}
	cout << ret << endl;

	return 0;
}

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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let sx = it.next().unwrap().parse::<i32>().unwrap();
    let sy = it.next().unwrap().parse::<i32>().unwrap();
    let tx = it.next().unwrap().parse::<i32>().unwrap();
    let ty = it.next().unwrap().parse::<i32>().unwrap();
    let dx = (tx - sx) as usize;
    let dy = (ty - sy) as usize;
    for _ in 0..dx { print!("R") }
    for _ in 0..dy { print!("U") }
    for _ in 0..dx { print!("L") }
    for _ in 0..dy+1 { print!("D") }
    for _ in 0..dx+1 { print!("R") }
    for _ in 0..dy+1 { print!("U") }
    print!("LU");
    for _ in 0..dx+1 { print!("L") }
    for _ in 0..dy+1 { print!("D") }
    println!("R");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    int X;
    cin >> X;
    vector<ll> A(8000,0);
    vector<ll> B(8000,0);
    rep(i,8000) {
        A.at(i) = (i-4000)*(i-4000)*(i-4000)*(i-4000)*(i-4000);
    }
    B = A;
    bool check = false;
    rep(i,8000) {
        rep(j,8000) {
            if (A.at(i)-B.at(j)==X) {
                cout << i-4000 << " " << j-4000 << endl;
                check = true;
                break;
            }
            // if (i==7999&&j==7999) {
            //     cout << "解なし" << endl;
            // }
        }
        if (check) break;
    }
}

Measured memory_bytes: 3760
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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 INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, ma, mb; cin >> n >> ma >> mb;
    vector<ll> a(n), b(n), c(n);
    REP(i, n) cin >> a[i] >> b[i] >> c[i];

    vector<vector<ll>> dp(401, vector<ll>(401, INF));
    dp[0][0] = 0;
    REP(i, n) {
        DSRNG(ga, 400-a[i], 0) {
            DSRNG(gb, 400-b[i], 0) {
                chmin(dp[ga+a[i]][gb+b[i]], dp[ga][gb] + c[i]);
            }
        }
    }

    ll ans = INF;
    for (ll ga = ma, gb = mb; ga <= 400 && gb <= 400; ga += ma, gb += mb) {
        chmin(ans, dp[ga][gb]);
    }
    cout << (ans < INF ? ans : -1) << endl;
    
}

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

int d, n;
int a[100], e[100], r[100];

int dp[101][101];

void solve()
{
	fill_n(*dp, 101 * 101, 1 << 28);
	dp[0][0] = 0;

	for (int i = 0; i < d; i++){
		for (int j = 0; j <= 100; j++){
			for (int k = 0; k < n; k++){
				if (j < r[k]) continue;
				int nd = min(d, i + a[k]);
				int ne = min(100, j + e[k]);
				dp[nd][ne] = min(dp[nd][ne], dp[i][j] + 1);
			}
		}
	}

	int res = 1 << 28;
	for (int i = 0; i <= 100; i++){
		res = min(res, dp[d][i]);
	}

	if (res == (1 << 28)) cout << "NA" << endl;
	else cout << res << endl;
}

int main()
{
	while (cin >> d >> n, d){
		for (int i = 0; i < n; i++){
			cin >> a[i] >> e[i] >> r[i];
		}
		solve();
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

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;
}

signed main()
{
    
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(ALL(a));
    COMinit();
    int mi = 0;
    for (int i = 0; i <= n-k; i++)
    {
        mi += a[i] * COM(n - (i + 1), k - 1);
        mi %= MOD;
    }
    int ma = 0;
    for (int i = k - 1; i < n; i++)
    {
        ma += COM(i, k - 1) * a[i];
        ma %= MOD;
    }
    cout << (ma + MOD - mi) % MOD << endl;

    return 0;
}

Measured memory_bytes: 13564
#include<iostream>
using namespace std;
int main(){
    string S;
    cin>>S;
    int win = 0;
    int lose = 0;
    int N = S.length();
    for(int i=0;i<N;++i){
        if(S[i]== 'o') ++win;
        else ++lose;
    }
    if(N==14&&win>=7) cout<<"YES"<<endl;
    else if(win>=8) cout<<"YES"<<endl;
    else if(lose<=7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long> d(n);

	for (long i = 0; i < n; i++) {
		cin >> d[i];
	}

	long res=0;
	for (long i = 0; i < n-1; i++) {
		for (long j = i + 1; j < n; j++) {
			res += d[i] * d[j];
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int w = sc.nextInt();

		for (int i = 0; i < s.length; i += w) {
			pr.print(s[i]);
		}
		pr.println();
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

template<typename T>
T gcd(T a, T b) {
    if (a%b == 0) return b;
    return gcd(b, a%b);
}

template<typename T>
void prime(T x, map<T, T>& cnt) {
    for (T i = 2; i*i <= x; ++i) {
        int c = 0;
        while (x%i == 0) {
            x /= i;
            c++;
        }
        if (c) cnt[i] += c;
    }
    if (x > 1) cnt[x] += 1;
}

int main(int argc, char **argv) {
    i64 n;
    cin >> n;
    vector<i64> a(n, 0), pr(1000000+1,0);
    for (int i=0; i<n; ++i) {
        cin >>a[i];
    }

    bool unique{true};
    i64 max_pr{0};
    for (int i=0; i<n; ++i) {
        i64 x = a[i];
        for (i64 j=2; j*j <= x; ++j) {
            bool first{true};
            while (x%j == 0) {
                x /= j;
                if (first) {
                    if (pr[j] != 0) unique = false;
                    ++pr[j];
                    max_pr = max(max_pr, pr[j]);
                    first = false;
                }
            }
        }
        if (x > 1) {
            if (pr[x] != 0) unique = false;
            ++pr[x];
            max_pr = max(max_pr, pr[x]);
        }
    }
    if (max_pr == n) {
        cout << "not coprime" << endl;
        return 0;
    }
    if (unique) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }
    /*
    unique = false;
    pr = vector<i64>(1000000+1,0);
    for (int i=0; i<n; ++i) {
        map<i64, i64>& cnt = prime_cnt[i];
        bool is_prime{true};
        for (auto kv : cnt) {
            ++pr[kv.first];
            if (i==n-1 && pr[kv.first] == n) {
                cout << "not coprime" << endl;
                return 0;
            }
        }
    }
    cout << "setwise coprime" << endl;
    */


    return 0;
}

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

using namespace std;




int main(){

	int n, k; cin >> n >> k;


	vector <int> a(n);


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

	int cnt = 0;

	for(int i = 0; i < n; i++){
		if(a[i] >= k){
			cnt++;
		}
	}


	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [float('inf')]*N
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[N-1])

Measured memory_bytes: 55264
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			if(left&&right)
				cnt++;
		}
		if(ans<cnt)
			ans=cnt;
	}
	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++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll A, B, K; cin >> A >> B >> K;
    cout << max(0LL, A-K) << " " << max(0LL, B - max(K-A,0LL)) << endl;
    return 0;
}


Measured memory_bytes: 256
#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 ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e6+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

const int N = 25;

int n, m;
char a[N][N];
int vis[N][N], dist[N][N];
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};

int bfs(int x, int y)
{
	memset(vis, 0, sizeof(vis));
	queue<pi>q;
	q.push({x, y});
	vis[x][y]=1;
	dist[x][y]=0;
	int mx = 0;
	while(!q.empty()){
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++){
			int nx=x+dx[dir];
			int ny=y+dy[dir];
			if(nx<1 || ny<1 || nx>n || ny>m || a[nx][ny] == '#')
				continue;
			if(!vis[nx][ny]){
				dist[nx][ny]=dist[x][y]+1;
				mx = max(mx, dist[nx][ny]);
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
	return mx;
}


int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(a[i][j] == '.'){
				ans = max(ans, bfs(i, j));
			}
		}
    }

	cout << ans <<endl ;

	return 0;
}


Measured memory_bytes: 71936
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll n, a[100000], l1, l2, r1, r2, mid1, mid2;
  ll m, ans = 0, sum[100001];
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  l1 = 0;
  r1 = 300000;
  sum[n] = 0;
  sort(a, a + n);
  for (ll i = n - 1; i >= 0; i--) {
    sum[i] = sum[i + 1] + a[i];
  }
  while (l1 <= r1) {
    mid1 = (l1 + r1) / 2;
    ll cnt = 0LL;
    for (ll i = 0; i < n; i++) {
      l2 = 0;
      r2 = n - 1;
      while (l2 <= r2) {
        mid2 = (l2 + r2) / 2;
        if (a[mid2] + a[i] >= mid1) {
          r2 = mid2 - 1;
        } else {
          l2 = mid2 + 1;
        }
      }
      cnt += (ll)(n - l2);
    }
    if (cnt <= m) {
      r1 = mid1 - 1;
    } else {
      l1 = mid1 + 1;
    }
  }
  ll cnt = 0LL;
  for (ll i = 0; i < n; i++) {
    l2 = 0;
    r2 = n - 1;
    while (l2 <= r2) {
      mid2 = (l2 + r2) / 2;
      if (a[mid2] + a[i] >= l1) {
        r2 = mid2 - 1;
      } else {
        l2 = mid2 + 1;
      }
    }
    cnt += (ll)(n - l2);
    ans += sum[l2];
    ans += (ll)((n - l2) * a[i]);
  }
  printf("%lld\n", ans + (ll)(m - cnt) * (ll)(r1));
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
	int N, K;
	int card[512][512];
	int d[1024];

	scanf("%d %d", &N, &K);

	for (int i = 0; i < K; i++){
		for (int j = 0; j < N / 2; j++){
			scanf("%d", &card[i][j]);
		}
	}

	unsigned int s = (unsigned int)time(NULL);
	srand(s);
	
	while (1){
		bool flag = true;
		for (int i = 0; i < N; i++){
			d[i] = ((unsigned int)rand()) % 2;
		}
		for (int i = 0; i < K; i++){
			int ans = 0;
			for (int j = 0; j < N / 2; j++){
				ans += d[card[i][j] - 1];
			}
			if (!(N / 8 <= ans && ans <= 3 * N / 8)){
				flag = false;
				break;
			}
		}
		if (flag == true){
			break;
		}
	}
	for (int i = 0; i < N; i++){
		printf("%d", d[i]);
	}
	printf("\n");

	return (0);
}

Measured memory_bytes: 2036
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 100000;
    int N, K, x[MAX_N];
    cin >> N >> K;
    REP(i, N) {
        cin >> x[i];
    }
    int res = 300000000;
    FOR(l, 0, N - K + 1, 1) {
        int r = l + K - 1;
        int lx = abs(x[l]), rx = abs(x[r]);
        if (lx <= rx) {
            amin(res, lx + x[r] - x[l]);
        } else {
            amin(res, rx + x[r] - x[l]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 768
n, m = map(int, input().split())
a = [0] * (n+1)
b = [list(map(int, input().split())) + [i] + [0] for i in range(m)]
b.sort(key= lambda x:x[1])
for i, (v, x, y, z) in enumerate(b):
    a[v-1] += 1
    b[i][3] = a[v-1]
b.sort(key = lambda x:x[2])
for v,x,y,z in b:
    print("{0:06d}{1:06d}".format(v,z))

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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int N = 1e5 + 10;
bool vis[N];
int n, head[N], cnt, ans[N];
struct Edge { int v, next, w; } edge[N * 2];
inline void add(int u, int v, int w) {
    edge[++cnt].v = v; edge[cnt].w = w; edge[cnt].next = head[u]; head[u] = cnt;
    edge[++cnt].v = u; edge[cnt].w = w; edge[cnt].next = head[v]; head[v] = cnt;    
}

void dfs(int u, int c) {
    ans[u] = c;
    vis[u] = 1;
    for (int i = head[u]; i; i = edge[i].next) {
        int v = edge[i].v;
        if (vis[v]) continue;
        if (edge[i].w & 1) dfs(v, c ^ 1);
        else dfs(v, c);
    }
}

int main() {
    n = read();   
    for (int i = 0; i < n - 1; i++) {
        int u = read(), v = read(), w = read();
        add(u, v, w);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int w, h;
int c[51][51];
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

void dfs(int y, int x){
	c[y][x] = 0;
	for(int i = 0; i < 8; i++){
		int ny = y + dy[i], nx = x + dx[i];
		if(0<=ny and ny<h and 0<=nx and nx<w and c[ny][nx]==1){
			dfs(ny, nx);
		}
	}
}

int solve(){
	int res = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(c[i][j] == 1){
				dfs(i, j);
				res++;
			}
		}
	}

	return res;
}

int main(void){
	while(scanf("%d%d", &w, &h) != EOF){
		if(w == 0 and h == 0) break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%d", &(c[i][j]));
			}
		}
		printf("%d\n", solve());
	}

	return 0;
}



Measured memory_bytes: 3184
#include <stdio.h>
#include <ctype.h>
int main(){
    char ch;
    while (1){
        scanf("%c", &ch);
        if(ch=='\n')
		{printf("\n");return 0;}
		if (isupper(ch)){printf("%c", tolower(ch));}
        else            {printf("%c", toupper(ch));}
    }
}

Measured memory_bytes: 524
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(void){
   ll N;
   cin  >> N;
   string S;
   cin >> S;
   ll rcnt=0,cnt = 0;
   rep(i,N){
       if(S.at(i)=='R'){
           rcnt++;
       }
   }
   rep(i,rcnt){
       if(S.at(i)=='W'){
           cnt++;
       }
   }
   cout << cnt << endl;
}

Measured memory_bytes: 3712
var rows = require("fs").readFileSync("/dev/stdin", "utf8").split("\n")

var N = rows[0].split(" ")[0]
var K = parseFloat(rows[0].split(" ")[1])
var h = rows[1].split(" ").map(parseFloat)

console.log(h.filter(function (x) { return x >= K }).length)


Measured memory_bytes: 28620
import java.util.*;
class Main{
    public static void main(String[] args) {
       Scanner stdIn = new Scanner(System.in); 
       int n = stdIn.nextInt();
       int[] w = new int[n];
       int s1 = 0;
       int s2 = 0;
       for(int i = 0; i < n;i++){
            w[i] = stdIn.nextInt();
            s1 += w[i];
       }
       int min = Math.abs(s1 - s2);
       for(int i = n - 1 ; i >= 0 ; i--){
           s1 -= w[i];
           s2 += w[i];
           if(Math.abs(s1 - s2) < min)
           min = Math.abs(s1 - s2);
       } 
       System.out.println(min);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define finish(x) reutrn cout << x << endl, 0;
#define ll long long
 //upsolve. other coder's code 
int d, dp[10001][101][2], mod = 1e9 + 7;
string k;
string c;
 
int solve(int ind, int cur, int b){
    if(ind == k.size()) return cur == 0;
    int &ret = dp[ind][cur][b];
    if(ret != -1) return ret;
    ret = 0;
    for(int i = 0 ; i <= (b == 0 ? k[ind] - '0' : 9) ; i++)
        ret = (ret + solve(ind + 1, (cur + i) % d, b || (i < k[ind] - '0'))) % mod;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> k >> d;
    cout << (solve(0, 0, 0) - 1 + mod) % mod << endl;
}

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

int main() {
	int N;
	cin >> N;
	set<ll> Z, W;
	for(int i = 0; i < N; i++){
		ll x,y;
		cin >> x >> y;
		Z.insert(x-y);
		W.insert(x+y);
	}
	ll z,w;
	z = *Z.rbegin() - *Z.begin();
	w = *W.rbegin() - *W.begin();

	ll mx = (z < w ? w : z);
	cout << mx << endl;
	return(0);
}


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

using namespace std;

const int maxN = 1E5 + 5;

int n, m, p[maxN], d[maxN], ans = 0;
vector<int> a[maxN];

vector<int> BFS(int u, int x)
{
    queue<int> q;
    vector<int> t;
    q.push(u); t.push_back(u); d[u] = x;
    while (!q.empty())
    {
        u = q.front(); q.pop();
        for (int v: a[u]) if (!d[v])
            q.push(v), t.push_back(v), d[v] = x;
    }
    return t;
}

void solve()
{
    memset(d, 0, sizeof d);
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (d[i]) continue;
        vector<int> v = BFS(i, ++cnt);
        for (int u: v) ans += (d[p[u]] == cnt);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
    for (int i = 1; i <= m; ++i)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        a[u].push_back(v); a[v].push_back(u);
    }
    solve();
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7164
#全てのますに対して
#もし#なら、四方の１つでも#ならok
#孤立まんがいたらアウト

H,W= map(int,input().split())
le = [input() for i in range(H)]
answer = [['0' for i in range(W)] for j in range(H)]

ass='Yes'
for i in range(0,H):
    for j in range(0,W):
        bool=False

        if le[i][j]!='#':
            continue
            
        if (i!=H-1):
            if(le[i+1][j]=='#'):
    
                bool=True


        if (i!=0):
            if(le[i-1][j]=='#'):
    
                bool=True
    
        if (j!=W-1):
            if(le[i][j+1]=='#'):
    
                bool=True

        if (j!=0):
            if(le[i][j-1]=='#'):

                bool=True


        if bool==False:
            ass="No"
            break

print(ass)

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N,0);
  vector<int> Y(N,0);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  sort(Y.begin(),Y.end());
  int A=Y.at((N-1)/2);
  int B=Y.at((N+1)/2);
  for(int i=0;i<N;i++){
    if(X.at(i)<=A){
      cout << B << endl;
    }else{
      cout << A << endl;
    }
  }
}

Measured memory_bytes: 3712
#!/usr/bin/env ruby

while line = gets
  n=line.chomp!.to_i

  cnt = 0

  0.upto(9) do |a|
    0.upto(9) do |b|
      0.upto(9) do |c|
        0.upto(9) do |d|
          cnt += 1 if (a+b+c+d) == n
        end
      end
    end
  end

  puts cnt
end

Measured memory_bytes: 8664
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
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;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif
#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define speedforces std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

signed main(){
  //input_from_file;
  speedforces;
  int n,k; cin>>n>>k;
  vector<int> dp(k+1); dp[0] = 2;
  vector<int> stn(n+1);
  fori(1,n+1) cin>>stn[i];
  fori(1,k+1){
    dp[i] = 2;
    forj(1,n+1) if(stn[j] <= i && dp[i-stn[j]] == 2) dp[i] = 1;
  }
  show(dp);
  if(dp[k] == 1) cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i) {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}


void Main() {
    ll N;
    cin >> N;
    set<ll> ans;
    ll x = pow(N, 0.5) * 10;
    rep2(k, 2, x + 1) {
        ll n = N;
        while (n >= k) {
            if (n % k) {
                n = n % k;
            } else {
                n = n / k;
            }
        }
        if (n == 1) ans.insert(k);
    }
    auto X = divisor(N - 1);
    for (auto z : X) {
        ans.insert(z);
    }
    ans.insert(N);
    ans.erase(1);
    cout << ans.size() << '\n';
}

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


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a > b) tmp = a, a = b, b =tmp;
    if(b > c) {
        tmp = b, b = c, c = tmp;
        if(a > b) tmp = a, a = b, b = tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n,k,t,u,v,l;
  cin >> n >> k >> t >> u >> v >> l;
  k=(k+1)*v*t;
  vector<int> d;
  d.assign(l+10,0);
  REP(i,n){
    int tmp;
    cin >> tmp;
    d[tmp]++;
  }
  vector<int> dp;
  dp.resize(l+10);
  dp[0]=0;
  int speed;
  REP(i,l){
    dp[i]+=d[i]*v*t;
    dp[i]=min(dp[i],k);
    dp[i+1]=max(0,dp[i]-1);
    if(dp[i]) speed++;
  }
  cout << fixed << 1.0*speed/v + 1.0*(l-speed)/u << endl;
  return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
string t;
ll r, s, p;

ll zyanken(ll i, ll j){
    if(t[i] == 'r'){
        if(j == 2) return p;
        else return 0; 
    }else if(t[i] == 's'){
        if(j == 0) return r;
        else return 0;
    }else if(t[i] == 'p'){
        if(j == 1) return s;
        else return 0;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, k; cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    ll dp[100010][3];
    rep(i, n)rep(j, 3) dp[i][j] = 0;
    
    rep(i, n){
        if(i < k){
            rep(j, 3) dp[i][j] = zyanken(i, j);
        }else{
            rep(j, 3)rep(l, 3){ // i+k回目にl、i回目にj 
                if(j != l){
                    dp[i][l] = max(dp[i - k][j] + zyanken(i, l), dp[i][l]);
                }
            }
        }
    }
    ll ans = 0;
    _rep(i, n - k, n){
        ans += max({dp[i][0], dp[i][1], dp[i][2]});
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6052
# coding: utf-8
# Your code here!
import sys
from sys import stdin
import numpy as np

def main():
    #pass
    n = int(stdin.readline().rstrip())
    p = np.array([int(x) for x in stdin.readline().rstrip().split()])
    #print(n,p_list,type(p_list))
    count=0
    for i in range(1,n-1):
        #print(p[i])
        #p_list[i+1] p_2
        if p[i-1]<p[i]<=p[i+1]:
            count+=1
        if p[i-1]>=p[i]>p[i+1]:
            count+=1
    print(count)
    return

if __name__ == "__main__":
    main()



Measured memory_bytes: 12436
#include <stdio.h>
int main(void)
{
	int a, b, c, n = 0;
	scanf("%d %d %d", &a, &b, &c);
	int i = a;
	while(i <= b)
	{
		if(c % i == 0)
		{
			n++;
		}
		i++;
	}
	printf("%d\n", n);
	return 0;

}




Measured memory_bytes: 2088
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void solve() {
	int H, N; cin >> H >> N;
	int sum = 0;
	REP(i, N) {
		int x; cin >> x;
		sum += x;
	}
	if (sum >= H)print("Yes");
	else print("No");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n, sum = 0;
    cin >> n;
    ll a[2 * n];
    for (int i = 0; i < 2 * n; i++)
        cin >> a[i];
    sort(a, a + 2 * n);
    for (int i = 0; i < 2 * n; i += 2)
        sum += a[i];
    cout << sum;
    return 0;
}

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

int main(void){
    // Your code here!
    string S;cin>>S;
    long long r,b;r=b=0;
    for(long long i=0;i<S.size();i++){
        if(S[i]=='0'){
            r++;
        }
        else{
            b++;
        }
    }
    cout<<min(r,b)*2<<endl;
    return 0;
}


Measured memory_bytes: 3736