akhauriyash/Code-Regression huggingface dataset:
import os
from io import BytesIO, IOBase
import sys
def main():
    s = int(input())
    dp = [0] * (s + 1)
    dp[0] = 1
    mod = 10 ** 9 + 7
    for i in range(3, s + 1):
        for j in range(3, i + 1):
            dp[i] = (dp[i] + dp[i - j]) % mod
    print(dp[-1])
# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9408
import sys
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]

for i in range(N):
    for j in range(i, N):
        p = [v for v in L]
        p[i], p[j] = p[j], p[i]
        
        f = True
        for k in range(N - 1):
            if p[k] > p[k + 1]:
                f = False
                break
        if f:
            print("YES")
            exit()
            
print("NO")


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        PrimeNumber PN = new PrimeNumber();
        
        while(0 < a){
            if(PN.getPN(sc.nextInt())){
                PN.result++;
            }
            a--;
        }
        System.out.println(PN.getResult());
    }
}

class PrimeNumber{
    int result = 0;
    
    public boolean getPN(int a){
        if(a == 2){
            return true;
        }
        if(a < 2 || a % 2 == 0){
            return false;
        }
        
        int k = 3;
        for(int i = 3; i <= Math.sqrt(a); i += 2){
            if(a % i == 0){
                return false;
            }
        }
        return true;
    }
    
    public int getResult(){
        return result;
    }
}



Measured memory_bytes: 40900
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define N 100000

typedef struct {
    char mark;
    int value;
} CARD;

CARD A[N];

int partition(int p, int r) {
    
    int x = A[r].value, i = p - 1, j, tmp_m, tmp_v;
    
    for (j = p; j < r; j++) {
        if (A[j].value <= x) {
            i++;
            tmp_m = A[i].mark;
            tmp_v = A[i].value;
            A[i].mark = A[j].mark;
            A[i].value = A[j].value;
            A[j].mark = tmp_m;
            A[j].value = tmp_v;
        }
    }
    tmp_m = A[i + 1].mark;
    tmp_v = A[i + 1].value;
    A[i + 1].mark = A[r].mark;
    A[i + 1].value = A[r].value;
    A[r].mark = tmp_m;
    A[r].value = tmp_v;
    
    return i + 1;
}

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

int main(void){
    int i, j, n, flg = 0 , stable[N]={}, k;
    CARD bef[N];
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
      scanf("%*c%c%d", &A[i].mark, &A[i].value);
      bef[i].value = A[i].value;
      bef[i].mark = A[i].mark;
    }

    quicksort(0, n - 1);
    
    flg = 0;
    
    for (i = 0; i < n; i++) {
        j = 0;
        k = 0;
        while (j <= stable[A[i].value]) {
            if (bef[k].value == A[i].value) {
                j++;
            }
            k++;
        }
        stable[A[i].value]++;
        j--;
        if(bef[j].mark != A[i].mark) {
            flg = 1;
            break;
        }
    }
    
    if(flg) printf("Not stable\n");
    else printf("Stable\n");
    
    for (i = 0; i < n; i++) {
        printf("%c %d\n", A[i].mark, A[i].value);
    }
    
    return 0;
}




Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}

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

    int N=in();
    vector<int> h(N);
    REP(i, N) cin >> h[i];
    
    vector<int> dp(N,INF);
    dp[0]=0;
    REP1(i,N-1){
        dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i-2<0)continue;
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));

    }
    cout<<dp[N-1]<<endl;


    return 0;
}

Measured memory_bytes: 1024
def solve(a):
 n = len(a)
 cost = [[0 for i in range(n)] for j in range(n)]
 for length in range(2, n+1):
  for i in range(0, n-length+1):
   k = i+length-1
   def f(i,j,k):
    return cost[i][j-1]+cost[j][k]+M[i][0]*M[j-1][1]*M[k][1]
   cost[i][k] = min([f(i,j,k) for j in range(i+1,k+1)])
 return cost[0][n-1]
n = input()
M = []
for i in range(n):
 M.append(map(int, raw_input().split()))
print solve(M)

Measured memory_bytes: 6576
using System;
using System.Collections.Generic;

class Program {
  static void Main (string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    var r = a * b / 2;
    Console.WriteLine(r);
  }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int cur=0;
    string S;
    cin>>S;
    while(cur<S.size()&&S[cur]!='C')cur++;
    if(cur==S.size()){
        cout<<"No"<<endl;
        return 0;
    }
    while(cur<S.size()&&S[cur]!='F')cur++;
    cout<<(cur!=S.size()?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,T,c,t,min_c=10000,flag=0;
    cin >> N >> T;
    for(int i=0;i<N;i++){
        cin >> c >> t;
        if(t<=T){
            flag=1;
            if(min_c>c) min_c = c;
        }
    }
    if(!flag) cout<<"TLE";
    else cout<<min_c;
}

Measured memory_bytes: 384
N = int(input())
t = []
index = {}
for n in range(N):
    si, ti = input().split()
    ti = int(ti)
    index[si] = n
    t.append(ti)

X = input()

ans = 0
for i in range(index[X]+1, N):
    ans += t[i]

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define ll long long
using namespace std;

int i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    REP(i,n)cin>>h[i];
    int dp[n];
    
    REP(i,n)dp[i]=INT32_MAX;
    dp[0]=0;

    for(i=1;i<n;i++){
        for(j=1;j<=min(i,k);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
        //cout<<dp[i]<<" ";
    }

    cout<<dp[n-1]<<'\n';
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

static class Extentions
{
}

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var xs = io.Is(3);
        Array.Sort(xs);

        if (xs[0] == xs[1]) io.Write(xs[2]);
        else io.Write(xs[0]);
    }
}

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

int main() {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a.at(i);
  ll ans = 0;
  rep(i,n) ans += a.at(i);
  ans -= n;
  cout << ans << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/cf17-final/submissions/12544627
# B - Palindrome-phobia
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    a = s.count("a")
    b = s.count("b")
    c = s.count("c")

    print("YES" if max(a, b, c) <= min(a, b, c) + 1 else "NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
character(100) a,b,c
character x
read*,a,b,c
x="a"
do
	if(x=="a")then
		if(trim(a)=="")then
        	print"(A)","A"
        	exit
        else
        	x=a(1:1)
            a=a(2:)
       	endif
    else if(x=="b")then
			if(trim(b)=="")then
        		print"(A)","B"
        		exit
        	else
        		x=b(1:1)
            	b=b(2:)
       		endif
	else
		if(trim(c)=="")then
        	print"(A)","C"
        	exit
        else
        	x=c(1:1)
            c=c(2:)
       	endif
    endif
end do
end

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res);
    else return (a*res*res);
}



void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-1,flag=0,count=0;
    string S,T,U;
    int a,b;
    cin>>k>>a>>b;
    rep(i,a,b+1)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return;
        }
    }
    cout<<"NG";
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void)
{
	int i,n,j,g;
	for(j=0;j<4;j++)
	{
		scanf("%d %d",&i,&n);
		if(i==1)
		{
			g=6000*n;
		}
		else if(i==2)
		{
			g=4000*n;
		}
		else if(i==3)
		{
			g=3000*n;
		}
		else if(i==4)
		{
			g=2000*n;
		}
		printf("%d\n",g);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const int MAX = 21;
const ll mod = 1e9+7;

vector<vector<ll>> dp(MAX+1, vector<ll>(1 << MAX, -1));
vector<vector<int>> a(MAX, vector<int>(MAX, 0));
int n;

ll dfs(int i, int u){
    if(i == n && u == (1 << n) -1) return dp[i][u] = 1;
    if(i == n && u != (1 << n) -1) return dp[i][u] = 0;
    if(dp[i][u] != -1) return dp[i][u];
    ll num = 0;
    rep(j,n){
        if(a[i][j] &&  !(u & (1 << j))) (num += dfs(i+1,u|(1<<j))) %= mod;
    }
    return dp[i][u] = num;
}

int main(){
    cin >> n;
    rep(i,n){
        rep(j,n) cin >> a[i][j];
    }
    cout << dfs(0,0) << endl;
    return 0;
}

Measured memory_bytes: 377216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin>>n;
    string s; cin>>s;
    string ans = "No";
    
    if(s.substr(0,n/2)==s.substr(n/2,n)) ans ="Yes";

    cout << ans << ln;
    return 0;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 4015
#define mxnn 2000005
int black[mxn][mxn],white[mxn][mxn],bpos[mxn],wpos[mxn],dp[mxn][mxn];
int32_t main(){
sp;
int n;
cin >>n;
for(int i = 1;i<=2*n;i++){
    char c;
    int x;
    cin >>c >>x;
    if(c == 'B'){
        bpos[x] = i;
        for(int j = x;j<=n;j++){
            black[i][j]++;
        }
    }
    else{
        wpos[x] = i;
        for(int j = x;j<=n;j++){
            white[i][j]++;
        }
    }
}
for(int i = 2*n-1;i>0;i--){
    for(int j = 1;j<=n;j++){
        black[i][j] += black[i+1][j];
        white[i][j] += white[i+1][j];
    }
}
for(int i = 0;i<mxn;i++) for(int j = 0;j<mxn;j++) dp[i][j] = inf;
dp[0][0] = 0;
for(int i = 0;i<=n;i++){
    for(int j = 0;j<=n;j++){
        if(i != 0){
            dp[i][j] = min(dp[i][j],dp[i-1][j]+black[bpos[i]][i-1]+white[bpos[i]][j]);
        }
        if(j != 0){
            dp[i][j] = min(dp[i][j],dp[i][j-1]+black[wpos[j]][i]+white[wpos[j]][j-1]);
        }
    }
}
cout<<dp[n][n];
return 0;
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  
  int ans = 1e9+7;
  int all = 1 << N;
  
  for (int mask = 0; mask < all; mask++) {
    vector<int> level(M);
    int cost = 0;
    for (int i = 0; i < N; i++) {
      if ((mask >> i) & 1) {
        cost += C[i];
        for (int j = 0; j < M; j++) {
          level[j] += A[i][j];
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (level[j] < X) flag = false;
    }
    if (flag) ans = min(ans, cost);
  }
  
  if (ans == 1e9+7) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i)cin>>a[i];
    int m=0;
    int ans=n-k+1;
    for(int i=2;i<=n;){
        if(a[i]>a[i-1]){
            int len=0;
            while(i<=n&&a[i]>a[i-1]){
                len++;
                i++;
            }
            if(len>=k-1)m++;
        }
        else
            i++;
    }
    set<int>s;
    int l=1,r=k;
    for(int i=l;i<=r;++i)s.insert(a[i]);
    while(l<=r&&r<=n){
        r++;
        if(r>n)break;
        s.insert(a[r]);
        if(*(s.rbegin())==a[r]&&*(s.begin())==a[l])ans--;
        s.erase(a[l]);
        l++;
    }
    if(!m)cout<<ans<<endl;
    else cout<<ans-m+1<<endl;
}


Measured memory_bytes: 10368
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ok := true
	t, x, y := 0, 0, 0
	for i := 0; i < N; i++ {
		nt, nx, ny := sc.nextInt(), sc.nextInt(), sc.nextInt()
		diff := abs(x-nx) + abs(y-ny)
		if (nt-t) < diff || (nt-t)%2 != diff%2 {
			ok = false
		}
		t, x, y = nt, nx, ny
	}

	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


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

int main() {
	ll a, b, c; scanf("%lld%lld%lld", &a, &b, &c);
	ll A = a / 2, B = b / 2, C = c / 2;
	ll ans = min((a - A*2)*b*c, (b - B*2)*a*c);
	ans = min(ans, (c - C*2)*a*b);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h1, h2, k1, k2, a, b, c, d, H, K ;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d >> H >> K ;
     H = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
     K = k1*a + (k1/10)*c + k2*b + (k2/20)*d;
     
    if ( H > K ) cout << "hiroshi" << endl;
        else if ( H < K ) cout << "kenjiro" << endl;
        else cout << "even" << endl;
}



Measured memory_bytes: 3104
INF = 10 ** 5
n = gets.to_i
neccesary_people = []
(0...INF).each do |group_count|
  neccesary_people[group_count] = group_count * (group_count - 1)
end
if group_count = neccesary_people.find_index(n * 2)
  puts "Yes"
  puts group_count
  ans = Array.new(group_count) { Array.new }
  (0...group_count).to_a.combination(2).each.with_index(1) do |c, i|
    c.each do |group|
      ans[group] << i
    end
  end
  ans.each do |row|
    puts "#{group_count - 1} #{row.join(" ")}"
  end
else
  puts "No"
end

Measured memory_bytes: 17516
#include <bits/stdc++.h>
#include <string> 
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mid 2019
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
 
 ll power (ll x,ll n)
{
    ll i; /* Variable used in loop counter */
    ll number = 1;

    for (i = 0; i < n; ++i)
        number *= x;

    return(number);
}
int main()
{
    fastio;
   
        ll count=0,ans1=0,ans2=0,sum=0,index=-1,c=0,flag=0;
        ll x,i,j;
        cin>>x;
        for(i=-500;i<=500;i++)
        {
            if(flag==1)
            break;
            else
            {
                    
                for(j=-500;j<=500;j++)
                {
                     ans1=i*i*i*i*i;
                    ans2=j*j*j*j*j;
                    if(ans1-ans2==x){
                    cout<<i<<" "<<j<<endl;
                    flag=1;
                }
                }
            }
        }
       
    
  

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int n,m;
    cin >> n >> m;
    int ans= 1;
    vector<int> g();
    for(int i=1;i<=sqrt(m); i++){
        if(m%i==0){
            int ii= m/i;
            if(i>=n) ans= max(ii,ans);
            if(ii>=n) ans= max(i,ans);

        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

long long tbl[400][400];
bool unused[400][400];

int main() {
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			scanf("%lld",&tbl[i][j]);
		}
	}
	long long ans=0;
	for (int k=0;k<n;k++) {
		for (int i=0;i<n;i++) {
			for (int j=0;j<n;j++) {
				if (tbl[i][k]+tbl[k][j]<tbl[i][j]) {
					printf("-1\n");
					return 0;
				}
				if (tbl[i][k]+tbl[k][j]==tbl[i][j]) {
					if (i!=k&&k!=j) {
						//printf("%d %d %d\n",i,j,k);
						unused[i][j]=true;
					}
				}	
			}
		}
	}
	for (int i=0;i<n;i++) {
		for (int j=i+1;j<n;j++) {
			if (!unused[i][j]) ans+=tbl[i][j];
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
    int n, d, x, total, a, day;
    cin >> n >> d >> x;
    total = x;
    for(int i=0; i<n; i++){
        cin >> a;
        day = 1;
        while(day <= d){
            total++;
            day += a;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
using namespace std;

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

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

int main(void) {
  ll N; cin >> N;
  ll ans = 1LL;

  for (int i = 0; i < N; i++) {
    ll T; cin >> T;
    ans = lcm(ans, T);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define vi vector<int>
#define ii pair<int, int>
#define ll long long int
#define MAX 200010
#define MOD 1e9+7
#define endl '\n'
using namespace std;

int m[3][3];
int mk[3][3];

void mark(int x){
	REP(i, 0, 3){
		REP(j, 0, 3){
			if(m[i][j] == x){
				mk[i][j] = 1;
				return;
			}
		}
	}
}

int main()
{
   
	fastio;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	REP(i, 0, 3){
		REP(j, 0, 3){
			cin >> m[i][j];
			mk[i][j] = 0;
		}
	}

	int n;
	cin >> n;

	REP(i, 0, n){
		int x;
		cin >> x;
		mark(x);
	}

	bool bingo = false;
	REP(i, 0, 3){
		int c = 0;
		REP(j, 0, 3){
			if(mk[i][j]) c++;
		}
		if(c == 3){
			bingo = true;
		}
	}

	REP(i, 0, 3){
		int c = 0;
		REP(j, 0, 3){
			if(mk[j][i]) c++;
		}
		if(c == 3){
			bingo = true;
		}
	}

	int i = 0, j = 0;
	int c = 0;
	while(i < 3){
		if(mk[i][j]) c++;
		i++; j++;
	}
	if(c == 3) bingo = true;

	i = 2; j = 0;
	c = 0;
	while(i >= 0){
		if(mk[i][j]) c++;
		i--; j++;
	}
	if(c == 3) bingo = true;

	// REP(i, 0, 3){
	// 	REP(j, 0, 3){
	// 		cout << mk[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	if(bingo){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main()
{
    long long int n,m,k;
    cin>>n>>m>>k;
    long long int ans=0,allb=0;
    vector<int> a(n);
    vector<int> b(m);
    
    rep(i,n) cin>>a[i]; rep(i,m) cin>>b[i];
    
    rep(i,m) allb+=b[i];
    
    rep(i,1+n)
    {
        while(allb>k&&m>0)
        {
            m--;
            allb-=b[m];
        }
        if(allb>k) break;
        ans=max(m+i,ans);
        if(i==n) break;
        allb+=a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

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


int main() {
    int n, m; cin >> n >> m;
    vector<int> p(m), y(m);
    rep(i, m) {
        cin >> p[i] >> y[i];
        --p[i];
    }
    vector<vector<int>> vals(n, vector<int>());
    rep(i, m) {
        vals[p[i]].push_back(y[i]);
    }
    rep(i, n) sort(all(vals[i]));

    rep(i, m) {
        int v = p[i];
        int id = lower_bound(all(vals[v]), y[i]) - vals[v].begin();
        cout << setfill('0') << right << setw(6) << (v + 1) << setfill('0') << right << setw(6) << (id + 1) << endl;
    }
}


Measured memory_bytes: 7808
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    string s; cin >> s;
    if(s.back()=='s'){
        s += "es";
    } else {
        s += "s";
    }
    cout << s << '\n';
    
}


Measured memory_bytes: 3656
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

member = [A, B, C, D, E]
if N % min(member) == 0:
    answer = N // min(member) + 4
else:
    answer = N // min(member) + 5
print(answer)

Measured memory_bytes: 3064
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    ans=10^9
    for i in a
        num=i
        cnt=0
        while num%2==0
            num=div(num,2)
            cnt+=1
        end
        ans=min(cnt,ans)
    end
    println(ans)
end
main()

Measured memory_bytes: 112796
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;
#define INF 1e9
int main() {
	ll X, Y;
	cin >> X >> Y;
	ll ans = 0;
	for (ll i = 0; i < INF; ++i) {
		if (X <= Y) {
			ans++;
		}
		else {
			break;
		}
		X *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static long gcd(long a, long b)
	{
	    if (a < b) {
	    	return gcd(b , a);
	    }
	    
	    return b > 0 ? gcd(b, a % b) : a;
	}

	static long lcm(long a, long b)
	{
	    return a * b / gcd(a, b);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextInt();
		long B = sc.nextInt();
		System.out.println(lcm(A , B));
	}
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;
//Int mod = 998244353; 

int main() {
    Int a, b, c;
    cin >> a >> b >> c;
    dump(min(a, b) < c && c < max(a, b) ? "Yes" : "No");
    return 0;
}

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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << v[i].second; if(i!=num-1) cout << " ";}
  cout << endl;
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

const int INF = 1e9+1;
template <typename T>
void merge(vector<T> &a, int left, int mid, int right, int &num){
  int n1 = mid - left;
  int n2 = right - mid;
  vector<T> L(n1+1), R(n2+1);
  for(int i=0; i<n1; i++) L[i] = a[left+i];
  for(int i=0; i<n2; i++) R[i] = a[mid+i];
  L[n1] = INF;
  R[n2] = INF;
  int l_id = 0, r_id = 0;
  for(int i=left; i<right; i++){
    if(L[l_id] <= R[r_id]){
      a[i] = L[l_id];
      l_id++;
    }
    else{
      a[i] = R[r_id];
      r_id++;
    }
    num++;
  }

  return;
}

template <typename T>
void mergeSort(vector<T> &a, int left, int right, int &num){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(a, left, mid, num);
    mergeSort(a, mid, right, num);
    merge(a, left, mid, right, num);
  }
  return;
}
int main(){
  //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=ja
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  int num = 0;
  mergeSort(a, 0, n, num);
  
  print_vec(a);
  cout << num << endl;
  return 0;
}




Measured memory_bytes: 6768
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}

void solve()
{	
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans = 0;
	int val = 0;
	val = min(a,k);
	ans += val;
	a-=val;
	k-=val;
	val = min(b,k);
	b-=val;
	k-=val;
	val = min(c,k);
	ans-=val;
	cout<<ans<<endl;
	
	
}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}

Measured memory_bytes: 3596
let pr x = print_endline (string_of_int x)

let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l) in
  exp (String.length s - 1) []


let solve seq =
  let len = List.length seq in
  let (_,_,res) = List.fold_left (fun (cnt,pre,mv) x ->
                      if x != pre then
                        (cnt+1,x,min mv (max cnt (len - cnt)))
                      else (cnt+1,x,mv)) (0,List.hd seq,len) seq in res

let () = input_line stdin
         |> explode 
         |> List.map (fun x -> if x = '0' then 0 else 1)
         |> solve
         |> pr


Measured memory_bytes: 9728
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    ll sum = 0;
    rep(i,n){
        cin>>v[i];
        sum += v[i];
    }
    ll x=sum/n;
    ll ans = 0;
    rep(i,n){
        ans += abs(v[i]-x)*abs(v[i]-x);
    }
    ll ans2 = 0;
    rep(i,n){
        ans2 += abs(v[i]-(x+1))*abs(v[i]-(x+1));
    }
    ans = min(ans,ans2);
    ans2 = 0;
    rep(i,n){
        ans2 += abs(v[i]-(x-1))*abs(v[i]-(x-1));
    }
    ans = min(ans,ans2);
    cout<<ans<<endl;



    
return 0;
}


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

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.to();
    let k: u32 = iter.to();
    let v = (0..n).map(|_| iter.to::<u32>()).collect::<Vec<_>>();
    let c = v.into_iter().filter(|&x| x >= k).count();

    println!("{}", c);
}

Measured memory_bytes: 4352
import numpy as np

def countf(a):
    count = 0

    for i in range(1, a + 1):
        if(a % i == 0):
            count += 1
    
    return count

n = input()
n = int(n)

count = 0

ls = []

for i in range(1, n + 1, 2):
    if(countf(i) == 8):
        count += 1
        ls += [i]

'''   
print(ls)

print("ここまで")
'''

print(count)

Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
  int k;
  cin >> k;

  ll ans = 0;
  vector <int> x(3);
  int x1, x2, x3;
   for (x1 = 1; x1 <= k; x1++) {
     for (x2 = 1; x2 <= k; x2++) {
       for (x3 = 1; x3 <= k; x3++) {
         x[0] = x1;
         x[1] = x2;
         x[2] = x3;
         sort(x.begin(), x.end());

         int sub = gcd(x[0], x[1]);
         ans = ans + gcd(sub, x[2]);
       }
     }
   }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
 
binary = 2**(n)
 
lamps={i:[] for i in range(m)}
 
 
for i in range(m):
    temp=list(map(int,input().split()))
    lamps[i]=[temp[1:]]
ps=list(map(int,input().split()))
 
for i,p in enumerate(ps):
    lamps[i].append(p)
 
 
pattern=0
for i in range(binary,binary*2):
    check_flg=True
    i_binary = bin(i)
    switch = list(map(int, list(i_binary[2:])))
    for sws, on_flg in lamps.values():
        sums=0
        for s_index in sws:
            if switch[s_index] == 1:
                sums+=1
        if sums%2!=on_flg:
            check_flg=False
            break
    if check_flg:
        pattern+=1
print(pattern)

Measured memory_bytes: 3064
/**
*    created: 01.07.2020 13:23:48
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 int mod = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(101);
    rep(i,m) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    rep2(i,1,101) a[i] += a[i-1];
    cout << min(a[x], a[n]-a[x]) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;


int main(){
	int N;
	cin>>N;
	vector<int> a(N),b(N),c(N);
	for(int i=0;i<N;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	vector<vector<int>> ha(N,vector<int> (3,0));
	ha[0][0]=a[0];
	ha[0][1]=b[0];
	ha[0][2]=c[0];
	for(int i=1;i<N;i++){
		ha[i][0]=max(ha[i-1][1]+a[i],ha[i-1][2]+a[i]);
		ha[i][1]=max(ha[i-1][0]+b[i],ha[i-1][2]+b[i]);
		ha[i][2]=max(ha[i-1][0]+c[i],ha[i-1][1]+c[i]);
	}
	int ans =max(ha[N-1][0],ha[N-1][1]);
	ans=max(ans,ha[N-1][2]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6912
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;

	long ans = 2;
	auto N1 = N-1;
	for (long i = 2; i*i <= N1; ++i)
	{
		if (N1 % i == 0)
		{
			++ans;
			debug writeln(i);
			if (i != N1 / i)
			{
				++ans;
				debug writeln(N1 / i);
			}
		}
	}

	for (long i = 2; i*i <= N; ++i)
	{
		if (N % i == 0)
		{
			long x = N;
			while (x >= i)
			{
				if (x % i) break;
				x /= i;
			}
			if ((x-1) % i == 0)
			{
				++ans;
				debug writeln(i);
			}
			auto z = N / i;
			if (z == i) continue;
			auto y = N;
			while (y >= z)
			{
				if (y % z) break;
				y /= z;
			}
			if ((y-1) % z == 0)
			{
				++ans;
				debug writeln(z);
			}
		}
	}

	if (N == 2)
		writeln(1);
	else
		writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 256
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/say/;
use POSIX ();

my $N = <STDIN>;
my @as = split(/\s+/, <STDIN>);

my $average = do {
    my $sum = 0;
    $sum += $_ for @as;
    int(round($sum / $N));
};

my $diff = 0;
$diff += ($_ - $average) * ($_ - $average) for @as;
say $diff;

# taken from Math::Round
sub round {
    my $x;
    my $half = 0.50000000000008;
    my @res  = map {
        if ($_ >= 0) { POSIX::floor($_ + $half); }
        else { POSIX::ceil($_ - $half); }
    } @_;

    return (wantarray) ? @res : $res[0];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
int32_t main()
{
	int n;
	cin >> n;
	int x[n];
	for(int i = 0; i < n; i++) cin >> x[i];
	int ans = 1e17;
	sort(x,x+n);
	int start = x[0],end = x[n-1];
	for(int k = start; k <= end; k++)
	{
		int calc = 0;
		for(int i = 0; i < n; i++)
		{
			int tt = (x[i]-k)*(x[i]-k);
			calc += tt;
		}
		ans = min(ans,calc);
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
	int N; string C; cin>>N>>C;
	int r = count(C.begin(), C.end(), 'R');
	r -= count(C.begin(), C.begin()+r, 'R');
	cout<< r <<endl;
}


Measured memory_bytes: 3732
# almost the copy of answer #2730510 

def S(n):
    return sum(list(map(int, str(n))))

def norm(n):
    return n/S(n)

k = int(input())
j = 1
order = 1
for i in range(k):
    print(j)
    if norm(j+10**(order-1)) > norm(j+10**(order)):
        order += 1
    j += 10**(order-1)
    


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

void solve()
{
	int input;
	while(cin >> input)
	{
		int ans = 0;
		for(int a = 0; a < 10; ++a)
		{
			for(int b = 0; b < 10; ++b)
			{
				for(int c = 0; c < 10; ++c)
				{
					for(int d = 0; d < 10; ++d)
					{
						if(a + b + c + d == input)
						{
							++ans;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;

  int count = 0;
  int i=0,j=0;
  int x_a,x_b;

  while(i<=A){
    if(X<500*i)break;
    x_a = X - 500*i;
    i += 1;
    if(x_a>100*B+50*C){
      continue;
    }
    j = 0;
    while(j<=B){
      if(x_a<100*j)break;
      x_b = x_a - 100*j;
      j += 1;
      if(x_b>50*C){
        continue;
      }
      else{
        count += 1;
      }
    }
  }

  cout << count << endl;


  return 0;
}

Measured memory_bytes: 256