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

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> open(n, vector<int>(10));
	ff(i, 0, n) {
		ff(j, 0, 10) {
			cin >> open.at(i).at(j);
		}
	}
	vector<vector<int>> prof(n, vector<int>(11));
	ff(i, 0, n) {
		ff(j, 0, 11) {
			cin >> prof.at(i).at(j);
		}
	}
	int ans = -2000000000;
	ff(i, 1, 1 << 10) {
		int pre = 0;
		bitset<10> op(i);
		ff(j, 0, n) {
			int a = 0;
			ff(k, 0, 10) {
				if (op.test(k) == 1 && open.at(j).at(k) == 1) {
					a++;
				}
			}
			pre += prof.at(j).at(a);
		}
		ans = max(ans, pre);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n,k,q;
    cin>>n>>k>>q;

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

    vector<int> correct(n); //正解数
    for(int i=0; i<q; i++){
        correct[a[i]-1]++; //ここが1ずれることに注意
    }

    for(int i=0; i<n; i++){
        cout<<(k-q+correct[i]>0 ? "Yes" : "No")<<endl;
    }
}

Measured memory_bytes: 1408
#include<cstdio>
#define neko 100010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
int n,m,tag[neko],cnt[neko],ans;
int main()
{
	int x,y;
	scanf("%d%d",&n,&m);
	f(i,1,n)cnt[i]=1;tag[1]=ans=1;
	f(i,1,m)
	{
		scanf("%d%d",&x,&y);
		++cnt[y];if(tag[x]&&!tag[y])tag[y]=1,++ans;
		if(!(--cnt[x])&&tag[x])tag[x]=0,--ans;
	}printf("%d\n",ans);
}

Measured memory_bytes: 896
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys
 

def isfour(s):
  for i in s:
    if i == 'Y':
      return True
  return False


input()
if isfour(list(map(str, sys.stdin.readline().rstrip().split()))):
  print("Four")
else:
  print("Three")




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

int main(void) {
  int N;
  cin >> N;
  int L[N];
  for (int i = 0; i < N; i++) cin >> L[i];
  sort(L, L+N);
  int sum = 0;
  for (int i = 0; i < N-1; i++) sum += L[i];
  if (L[N-1] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  vector<pair<ll, ll>> cost_per_l(4);
  ll min_one_litter = min(S, min(Q * 4, H * 2));
  ll ans = 0;
  if (2 * min_one_litter < D) {
    ans = N * min_one_litter;
  } else {
    ans = (N / 2) * D + (N % 2) * min_one_litter;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A==B&&B==C){
    printf("No\n");
  }else if(A!=B&&B!=C&&A!=C){
    printf("No\n");
  }else{
    printf("Yes\n");
  }

  return 0;
}


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

int main() {
  int n; string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  if (s.substr(0,n/2) == s.substr(n/2,n/2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0,-1 }; // x軸方向への変位
int dy[4] = { 1, 0,-1, 0 }; // y軸方向への変位

int P[1000000];
int Q[1000000];
signed main() {
	int N;
	cin >> N;
	for (int i = 1; i<N+1; i++) {
		int t;
		cin >> t;
		P[i] = t;

		
	}
	for (int i = 1; i < N + 1; i++) {
		Q[P[i]] = i;
	}
	int count = 0;
	int now = -1;
	int maxLen = 0;
	for (int i = 1; i < N + 2; i++) {
		if (now < Q[i]) {
			count++;
			now = Q[i];
		}
		else {
			maxLen = max(maxLen, count);
			now = Q[i];
			count = 1;
		}
	}
	cout << N - maxLen << "\n";




	return 0;
}

Measured memory_bytes: 5888
def print_str(a, b, str) -> None:
    for i in range(a, b + 1):
        print(str[i], end="")
    print()


s = list(input())
n = int(input())
for i in range(n):
    cmd, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if (cmd == "print"):
        print_str(a, b, s)
    elif (cmd == "reverse"):
        s[a:b + 1] = reversed(s[a:b + 1])
    else:
        s[a:b + 1] = c[0]



Measured memory_bytes: 5744
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <climits>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> Pi;

const int INF=100000000;
const long long int INF_=100000000000000000;

lli Cmin(const lli a,const lli b){
	if(a<b) return a;
	else return b;
}

class SegmentTree{
	private:
	static const int MAX_N=1<<25;
	static lli dat[2*MAX_N-1];
	public:
	int n;
	void Init(int n_){
		n=1;
		while(n<n_) n*=2;
		for(int i=0; i<2*n-1; ++i) dat[i]=INF_;
	}
	void Update(int k,lli a){
		k+=n-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=Cmin(dat[k*2+1],dat[k*2+2]);
		}
	}
	lli Query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return INF_;
		if(a<=l&&r<=b) return dat[k];
		else {
			lli vl=Query(a,b,k*2+1,l,(l+r)/2);
			lli vr=Query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
	int GetData(const int k){
		return dat[k];
	}
};

lli SegmentTree::dat[2*MAX_N-1];

class SegmentTree_{
	private:
	static const int MAX_N=1<<25;
	static lli dat[2*MAX_N-1];
	public:
	int n;
	void Init(int n_){
		n=1;
		while(n<n_) n*=2;
		for(int i=0; i<2*n-1; ++i) dat[i]=INF_;
	}
	void Update(int k,lli a){
		k+=n-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=Cmin(dat[k*2+1],dat[k*2+2]);
		}
	}
	lli Query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return INF_;
		if(a<=l&&r<=b) return dat[k];
		else {
			lli vl=Query(a,b,k*2+1,l,(l+r)/2);
			lli vr=Query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
	int GetData(const int k){
		return dat[k];
	}
};

lli SegmentTree_::dat[2*MAX_N-1];

int Serialize(const int y,const int x,const int w){
	return x+y*w;
}

int Serialize_(const int y,const int x,const int h){
	return y+x*h;
}

int solve(){
	int R,C,Q;
	cin >> R >> C >> Q;
	if(R==0&&C==0&&Q==0) return 0;
	SegmentTree st;
	SegmentTree_ st_;
	st.Init(R*C);
	st_.Init(R*C);
	REP(y,0,R) REP(x,0,C){
		lli tmp;
		cin >> tmp;
		st.Update(Serialize(y,x,C),tmp);
		st_.Update(Serialize_(y,x,R),tmp);
	}
	/*
	REP(i,0,R*C+st.n-1) cout << st.GetData(i) << endl;
	cout << endl;
	*/
	REP(i,0,Q){
		int r[2],c[2];
		REP(j,0,2) cin >> r[j] >> c[j];
		lli ans=INF_;
		if(r[1]-r[0]<c[1]-c[0]) REP(y,r[0],r[1]+1) ans=Cmin(ans,st.Query(Serialize(y,c[0],C),Serialize(y,c[1]+1,C),0,0,st.n));
		else REP(x,c[0],c[1]+1) ans=Cmin(ans,st_.Query(Serialize_(r[0],x,R),Serialize_(r[1]+1,x,R),0,0,st_.n));
		cout << ans << endl;
	}
	//REP(i,0,R*C) cout << st.GetData(i) << endl;
	//REP(y,0,R) REP(x,0,C) cout << st.GetData(Serialize(y,x,C)) << endl;
	return 1;
}

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

Measured memory_bytes: 38024
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int n,m;
double xs[10005];
double ys[10005];

typedef pair<double,mp> dmp;

vector<dmp> es;

double dist(int a,int b){
	double x = xs[a]-xs[b],y=ys[a]-ys[b];
	//printf("%lf %lfs %lf %lf\n",xs[a],xs[b],x,y);
	return sqrt(x*x+y*y);
}

int uni[10005];

void init(){
	rep(i,10005){
		uni[i]=i;
	}
}

int find(int q){
	if(uni[q]==q)return uni[q];
	return (uni[q]=find(uni[q]));
}

void mer(int p,int q){
	uni[find(p)]=find(q);
}

bool same(int p,int q){
	return (find(p)==find(q));
}


int main(void){
	init();
	scanf("%d%d",&n,&m);
	rep(i,n){
		scanf("%lf%lf",&xs[i],&ys[i]);
	}
	double sw = 0;
	rep(i,m){
		int a,b;
		scanf("%d%d",&a,&b); a--; b--;
		double d = dist(a,b);
		sw+=d;
		//printf("%d %d %lf ",a,b,d);
		es.push_back(dmp(-d,mp(a,b)));
	}
	
	sort(es.begin(),es.end());
	
	double ans = sw;
	rep(i,m){
		dmp pa = es[i];
		double d = pa.fir;
		int a = pa.sec.fir,
			b = pa.sec.sec;
		if(same(a,b))continue;
		ans+=d;
		mer(a,b);
	}
	
	printf("%f\n",ans);
		
	return 0;
}

Measured memory_bytes: 1884
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ans[10005]={0};
signed main(){
	int n;
	cin>>n;
	for(int x=1;x<=105;x++){
		for(int y=1;y<=105;y++){
			for(int z=1;z<=105;z++){
				int res=x*x+y*y+z*z+x*y+y*z+z*x;
				if(res<10005)
					ans[res]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
         return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int A, B; cin >> A >> B;
  cout << max(0, A - 2 * B) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func group(n int) string {
	if n == 4 || n == 6 || n == 9 || n == 11 {
		return "B"
	} else {
		return "A"
	}
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	if x == 2 || y == 2 {
		fmt.Println("No")
		return
	}

	xg := group(x)
	yg := group(y)

	if xg == yg {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
"use strict";
function Main(input) {
  let result = 0;
  let arr = input.split("");
  for (const s of arr) {
    if (s === "1") {
      result = result + 1;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

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

  vvll dp(n+1, vll(h+10001, LINF));
  for(int i=0;i<=n;++i) {
    dp[i][0] = 0;
  }

  for(int i=0;i<n;++i) {
    for(int j=0;j<=h+10000;++j) {
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
      if(j - a[i] >= 0) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j-a[i]] + b[i]);
        dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-a[i]] + b[i]);
      }
    }
  }

  ll ans = LINF;
  for(int i=h;i<=h+10000;++i) {
    ans = min(ans, dp[n][i]);
  }
  cout << ans << endl;

}


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

int main(){
    int n, m=0;
    int a[101];
    vector<int> ans;

    for(int i=1 ; i <= 100 ; i++){
        a[i] = 0;
    }
    while( cin >> n ){
        a[n]++;
    }
    for(int i=1 ; i <= 100 ; i++){
        m = max( a[i] , m );
    }
    for(int i=1 ; i <= 100 ; i++){
        if( m == a[i] ) ans.push_back(i);
    }
    sort( ans.begin() , ans.end() );
    for(int i=0 ; i < ans.size() ; i++ ){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 0
n,m=map(int,input().split())
ac=[0]*n
pn=[0]*n
for i in range(m):
  ps=input().split()
  p=int(ps[0])-1
  s=ps[1]
  if ac[p]:
    continue
  if s=='AC':
    ac[p]=1
  else:
    pn[p]+=1
acs=sum(ac)
pns=sum([x for i,x in enumerate(pn) if ac[i]])
print(acs, pns)

Measured memory_bytes: 5424
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename Data, typename T>
struct ReRooting{
  struct Node{
    Int to,rev;
    Data data;
    Node(Int to,Int rev,Data data):to(to),rev(rev),data(data){}
  };
  
  using F1 = function<T(T,T)>;
  using F2 = function<T(T,Data)>;
  
  vector<vector<Node> > G;
  vector<vector<T> > ld,rd;
  vector<Int> lp,rp;
  
  const F1 f1;
  const F2 f2;
  const T id;

  ReRooting(Int n,const F1 f1,const F2 f2,const T id):
    G(n),ld(n),rd(n),lp(n),rp(n),f1(f1),f2(f2),id(id){}

  void add_edge(Int u,Int v,Data d){
    G[u].emplace_back(v,(Int)G[v].size(),d);
    G[v].emplace_back(u,(Int)G[u].size()-1,d);
  }

  T dfs(Int v,Int p){
    while(lp[v]!=p&&lp[v]<(Int)G[v].size()){
      auto &e=G[v][lp[v]];
      ld[v][lp[v]+1]=f1(ld[v][lp[v]],f2(dfs(e.to,e.rev),e.data));      
      lp[v]++;
    }
    while(rp[v]!=p&&rp[v]>=0){
      auto &e=G[v][rp[v]];
      rd[v][rp[v]]=f1(rd[v][rp[v]+1],f2(dfs(e.to,e.rev),e.data));
      rp[v]--;
    }
    if(p<0) return rd[v][0];
    return f1(ld[v][p],rd[v][p+1]);    
  }

  vector<T> build(){
    for(Int i=0;i<(Int)G.size();i++){
      ld[i].assign((Int)G[i].size()+1,id);
      rd[i].assign((Int)G[i].size()+1,id);
      lp[i]=0;
      rp[i]=(Int)G[i].size()-1;      
    }
    vector<T> res;
    for(Int i=0;i<(Int)G.size();i++){
      res.emplace_back(dfs(i,-1));
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,bs;
  Int uku=0;
  while(cin>>n>>bs,n){
    using P = pair<Int, Int>;
    auto f1=[&](P a,P b){
              if(a.first!=b.first) return max(a,b);
              return P(a.first,a.second+b.second);
            };
    auto f2=[&](P a,Int b){
              if(a.second+b<=bs) return P(a.first,a.second+b);
              return P(a.first+1,b);
            };
    P ti(0,0);
    ReRooting<Int, P> G(n,f1,f2,ti);
    for(Int i=1;i<n;i++){
      Int p;
      cin>>p;
      p--;
      G.add_edge(p,i,1);
    }    
    auto ans=G.build();
    cout<<"Case "<<++uku<<":"<<endl;
    for(Int i=0;i<n;i++) cout<<f2(ans[i],1).first+1<<"\n";
    cout<<flush;
  }
  return 0;
}



Measured memory_bytes: 74296
import numpy as np
n, p = map(int ,input().split())

def prime_decomposition(n):
    i = 2
    n0 = n
    primes = {}
    while i**2<n0:
        #print(i)
        if n%i==0:
            primes[i] = 0
        while n%i==0:
            n=n//i
            primes[i] += 1
        i += 1
    if n!=1:
        primes[n] = 1
    return primes

primes = prime_decomposition(p)
#print(primes)

ans = 1
for prime in primes:
    ans *= prime**(primes[prime]//n)

print(ans)

Measured memory_bytes: 14244
N = int(input())
H = list(map(int,input().split()))
Hsub = []
c = 0
for i in range(N-1):
    if H[i+1]-H[i] <= 0:
        c += 1
    else:
        Hsub.append(c)
        c = 0
Hsub.append(c)
print(max(Hsub))


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int a[3];
  for(int i = 0; i < 3; i++) cin >> a[i];
  ll ans = 1e9;
  sort(a, a + 3);
  do{
    ans = min(ans, (ll) abs(a[0] - a[1]) + abs(a[2] - a[1]));
  } while(next_permutation(a, a + 3));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
N = int(input())
S = list(input())
S = list(map(int, S))
first = [-1] * 10
#second = [-1] * 10
#third = [-1] * 10
ans = 0
for i in range(N):
    if first[S[i]] == 1:
        continue
    second = [-1] * 10
    for j in range(i + 1, N):
        if second[S[j]] == 1:
            continue
        third = [-1] * 10
        for k in range(j + 1, N):
            if third[S[k]] == 1:
                continue
            #print(S[i], S[j], S[k])
            ans += 1
            third[S[k]] = 1
        second[S[j]] = 1
    first[S[i]] = 1
print(ans)

Measured memory_bytes: 75388
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

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


using namespace std;


int main(void)
{
    int n;
    int money = 100000;
    cin >> n ;
    FOR(i, 1,n+1 )
    {
        money += money*0.05;
        if(money % 1000 != 0)
            money += 1000 -  (money % 1000);
    }

    cout << money << endl;
    return 0;
}

Measured memory_bytes: 1160
#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 ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long
set<int> ans;
void calc(int n){

	if(n > 3234566667)
		return;

	ans.insert(n);

	int prev = n%10;
	int end = prev+1;
	if(prev==9)
		end = 9;
	if(prev==0)
		prev = 1;
	for(int i = prev-1 ; i <= end ; ++i){

		int x = n*10 + i;
		calc(x);
	}
}

void solve(){

	for(int i = 1 ; i <= 9  ; ++i)
		calc(i);

	//cout<<ans.size()<<endl;
	vector<int> x(ans.begin(),ans.end());
	
	
	int k;
	cin>>k;
	cout<<x[k-1]<<endl;
}


signed main(){

    fast;
    //freopen("output.txt" , "w" , stdout);
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


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

 using namespace std;

 int main() {
   int A, B, C, D;

   cin >> A >> B >> C >> D;

   if (B <= C || D <= A) cout << 0 << endl;
   else if (A <= C) {
     if (B <= D) cout << B - C << endl;
     else cout << D - C << endl;
   }
   else if (D <= B) cout << D - A << endl;
   else cout << B - A << endl;
 }


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

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

  int64_t ans = 0;
  int ma = a[0];
  for(int i=1; i<n; i++) {
    if(a[i]>ma) {
      ma = a[i];
    }
    else {
      ans += ma-a[i];
    }
  }

  cout<<ans<<endl;

  return 0;
}

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

string S[200000];

int main() {
	int N;
	set<string> setS;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> S[i];
		setS.insert(S[i]);
	}

	cout << setS.size();
}

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

int main(){
  int n, a, mx;
  vector<int>vec, vec2;
  cin >> n;
  while(n--){
    cin >> a;
    vec.push_back(a);
    vec2.push_back(a);
  }
  sort(vec.rbegin(), vec.rend());
  // vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for(int i=0; i<vec2.size(); i++){
    if(vec2[i]<vec[0]){
      cout << vec[0] << endl;
    }
    else cout << vec[1] << endl;
  }
}


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

using namespace std;

int main(){
	string s;
	cin>>s;
	string ans="YES";

	for(int i=s.size()-1;i>=0;i--){
		bool no=false;

		if(i>=4){
			if(s.at(i)=='r' && s.at(i-1)=='e'){
				i-=2;
				if(s.at(i)=='s' && s.at(i-1)=='a' && s.at(i-2)=='r' && s.at(i-3)=='e'){
					i-=4;
				}else if(s.at(i)=='m' && s.at(i-1)=='a' && s.at(i-2)=='e' && s.at(i-3)=='r' && s.at(i-4)=='d'){
					i-=5;
				}else{
					no=true;
				}
			}else if(s.at(i)=='m' && s.at(i-1)=='a' && s.at(i-2)=='e' && s.at(i-3)=='r' && s.at(i-4)=='d'){
				i-=5;
			}else if(s.at(i)=='e' && s.at(i-1)=='s' && s.at(i-2)=='a' && s.at(i-3)=='r' && s.at(i-4)=='e'){
				i-=5;
			}else{
				no=true;
			}
		}else{
			no=true;
		}

		if(no){
			ans="NO";
			break;
		}

		i++;
	}

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

int main() {
    int n = 0, p = 0, cnt = 0;
    vector<int> vec;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> p;
        vec.push_back(p);
    }

    for (int i = 0; i < vec.size(); ++i) {
        if (i >= 1 && i < vec.size() - 1) {
            if (vec[i] > vec[i - 1] && vec[i] > vec[i + 1])continue;
            if (vec[i] < vec[i - 1] && vec[i] < vec[i + 1])continue;
            cnt++;
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3624
/*************************************************************************
    > File Name: A.cpp
    > Author: PumpkinYing
    > Created Time: 2018/8/18 20:04:28
 ************************************************************************/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
typedef long long ll;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",a*b-a-b+1);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;


ll N,M,A[100000],B[100000],ans;
pair<ll, ll>C[100000];

int main(void) {
	cin >> N >> M;
	FOR(i, 0, N) {
		cin >> C[i].first >> C[i].second;
	}
	sort(C, C + N);
	
	FOR(i, 0, N) {
		if (C[i].second >= M) {
			ans += M * C[i].first;
			break;
		}
		ans += C[i].second*C[i].first;
		M -= C[i].second;
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M) {
  ullong res = 1;
  if (n > 0) {
    res = power(x, n / 2, M);
    if (n % 2 == 0) res = (res * res) % M;
    else res = (((res * res) % M) * x) % M;
  }
  return res;
}

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

  cout << power(m, n, 1000000007) << endl;
  return 0;
}



Measured memory_bytes: 3124
N = int(input())
V = [ int(v) for v in input().split() ]
C = [ int(c) for c in input().split() ]

if N < 0 or 20 < N: raise()
for v in V:
    if v < 0 or 50 < v: raise()
for c in C:
    if c < 0 or 50 < c: raise()

cost_table = [ V[i] - C[i] for i in range(N) ]
mymax = 0
for i in range(N):
    if (mymax + cost_table[i] > mymax):
        mymax += cost_table[i]
print(mymax)


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

int main() {
  int N;
  cin >> N;
  map<string, int> MA;
  int mx = 0;
  for (string s; cin >> s;) mx = max(mx, ++MA[s]);
  for (auto ma : MA) if (ma.second == mx) cout << ma.first << "\n";
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

long double n, m, d;

int main() {
    cin >> n >> m >> d;
    long double ans = 0.0;
    if(d == 0.0) ans = (m-1LL) / n;
    else ans = (m-1LL) * 2LL * (n-d) / n / n;

    cout << setprecision(14) << ans << endl;
}

Measured memory_bytes: 3764
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N;
int a[100000],b[100000],c[100000];

int ans = 0;
 
void solve(){
	int A[100000],B[100000],C[100000];
	A[0] = a[0];B[0] = b[0];C[0] = c[0];
	for(int i=1;i<N;i++){
		A[i] = max(B[i-1],C[i-1]) + a[i];
		B[i] = max(A[i-1],C[i-1]) + b[i];
		C[i] = max(A[i-1],B[i-1]) + c[i];
	}
	ans = max(A[N-1],max(B[N-1],C[N-1]));
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> a[i] >> b[i] >> c[i];
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
def get_distance(x, y, d):
    result = 0
    for i in range(d):
        result += (x[i] - y[i]) ** 2
    return result

def is_2jou(i):
    ii = i ** 0.5
    if ii == float(round(ii)):
        return True
    else:
        return False

def main():
    n, d = map(int, input().split())
    x = []
    for _ in range(n):
        x.append([int(i) for i in input().split()])

    cnt = 0
    for _ in range(len(x)):
        head = x.pop(0)
        for j in x:
            distance = get_distance(head, j, d)
            flag = is_2jou(distance)
            if flag:
                cnt += 1

    print(cnt)

main()

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

const double pi=3.14159265358979323846;

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

  double theta1;
  theta1=atan(2*(pow(a,2)*b-x)/pow(a,3))*(180/pi);

  double theta2;
  theta2=90-atan(2*x/(a*pow(b,2)))*(180/pi);

  if(theta1<atan(b/a)*(180/pi)){
    printf("%f\n",theta1);
  }
  else{
    printf("%f\n",theta2);
  }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc003/tasks/agc003_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//なるべく次に余らせる
int main() {
    ll N; cin>>N;
    vector<ll> an(N+1,0);
    FOR(i,1,N+1){
        cin>>an.at(i);
    }

    auto decan = [](ll& av, ll val){
        av -= val; assert(av>=0);
    };

    ll ans=0;
    FOR(i,1,N+1){
        ll tmp=an.at(i)/2;
        ans += tmp;
        decan(an[i], tmp*2);
        //次のとマッチ
        if(i<N){
            ll nt=min(an.at(i), an.at(i+1));
            ans+=nt;
            decan(an[i+1],nt);
        }
    }
    cout<<ans<<endl;
    return 0;
}

int main_wa() {
#if LOCAL&01
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    vector<ll> an(N+1,0);
    FOR(i,1,N+1){
        cin>>an[i];
    }
    auto decan = [](ll& av, ll val){
        av -= val; assert(av>=0);
    };

    ll ans=0;
     FOR(i,1,N+1){
        ll tmp=max<ll>(an.at(i)-1,0);
        tmp /= 2;
        ans+=tmp;
        decan(an[i], tmp*2);
    }
    FOR(i,1,N){
         ll tmp=min(an.at(i), an.at(i+1));
         ans+=tmp;
         an[i]-=tmp; assert(an[i]>=0);
         an[i+1]-=tmp; assert(an[i+1]>=0);
    }
    FOR(i,1,N+1){
        ans+=an.at(i)/2;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

ll dp[1000001][2];

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE

	fastio;
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	s += "0";
	ll ans = 0;
	int n = s.size();
	vector<vector<ll>> dp(n + 1, vector<ll>(2, INF));
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 2; ++j) {
			int x = s[i] - '0';
			x += j;
			if (x < 10) dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + x);
			if (x > 0) dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + (10 - x));
		}
	}
	cout << min(dp[n][0], dp[n][1]);
	return 0;
}

Measured memory_bytes: 55964
#include<iostream>
#include<algorithm>
#include<vector>
int main()
{
  int N,K;std::cin>>N>>K;
  std::vector<int>h(N);
  for(auto& e:h)std::cin>>e;
  std::sort(h.begin(),h.end());
  int ans =1e9;
  for(int i=0;i+K<=N;i++)ans=std::min(ans,h[i+K-1]-h[i]);
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
int arr[100000]={0};
int main() {
     int x,y=10000;
     long long a=0,d=0;
     cin>>x;
     int arr[x];
     for(int i=0;i<x;i++){
         cin>>arr[i];
         if (((i+1)%2)==1&& (arr[i]%2)==1)
            a++;
     }
     cout<<a;


    }

Measured memory_bytes: 3644
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

long K,S,X,Y,cnt;
inline void solve(){
  IN2(K,S);
  UP(X,0,K){
    UP(Y,0,K){
      if(S-X-Y>=0&&S-X-Y<=K)cnt++;
    }
  }
  OUT(cnt);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
x = input()
x = "T" + x + "S"
ar = []
c = 1
for i in range(1, len(x)):
    if x[i-1] == x[i]:
        c += 1
    else:
        ar.append(c)
        c = 1
ar.append(c)

ssum = ar[1]
trem = ar[0]
for i in range(2, len(ar), 2):
    trem += max(0, ar[i]-ssum)
    ssum -= min(ssum, ar[i])
    ssum += ar[i+1]
print(ssum+trem-2)

Measured memory_bytes: 4388
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll MAXN = (ll)2e3+10;
const ll DIV = (ll)1e9+7;


int main(void) {
   ll N;
   cin>>N;
   cout<<(N-1)/2<<endl;


   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

long inversions = 0;

void merge(int A[], int left, int mid, int right) {
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1], R[n2+1];

  for (i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = INT_MAX;
  i = 0, j = 0;

  for (k = left; k < right; k++) {
    if (L[i] <= R[j])
      A[k] = L[i++];
    else {
      A[k] = R[j++];
      //if (i != n1 && j != n2)
      inversions += n1 - i;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n, i;

  scanf("%d", &n);

  int arr[n+5];

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

  mergeSort(arr, 0, n);

  printf("%ld\n", inversions);
}



Measured memory_bytes: 3348
#include <stdio.h>

#define MAXN 101 /*添字0は使わないから1多い*/
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef struct {
  int color;
  int d;
  int f;
} NODE;


void scanData(int [][MAXN],int);
void dfs(int [][MAXN], NODE *, int);
int visit(int [][MAXN], NODE *,int, int, int);


int main()
{
  int i, j, n;
  int M[MAXN][MAXN];
  NODE Node[MAXN];

  scanf("%d",&n);
  scanData(M, n);

  dfs(M,Node,n);

  for(i = 1; i <= n; i++) {
    printf("%d %d %d\n", i, Node[i].d, Node[i].f);
  }  
  return 0;
}

void scanData(int M[][MAXN], int n)
{
  int i, j, u, k, v;

  for(i = 1; i <= n; i++) {
    for(j = 1; j <= n; j++) {
      M[i][j] = 0;
    }
  }

  for(i = 1; i <= n; i++) {
    scanf("%d%d",&u,&k);

    for(j = 1; j <= k; j++) {
      scanf("%d",&v);
      M[i][v] = 1;
    }
  }
}

void dfs(int M[][MAXN], NODE *Node, int n)
{
  int i, time = 0;
  
  for(i = 1; i <= n; i++) {
    Node[i].color = WHITE;
  }
  for(i = 1; i <= n; i++) {
    if(Node[i].color == WHITE) time = visit(M, Node, n, time, i);
  }
}

int visit(int M[][MAXN], NODE *Node, int n, int time, int u)
{
  int i, v;
  Node[u].color = GRAY;
  Node[u].d = ++time;
  for(v = 1; v <= n; v++) {
    if(M[u][v] == 1 && Node[v].color == WHITE) time = visit(M, Node, n, time, v);
  }
  Node[u].color = BLACK; /*finished*/
  Node[u].f = ++time;

  return time;
}


  



Measured memory_bytes: 2076
joukyuukokuminndomo=input().split(' ')
joukyuukokuminn2=int(joukyuukokuminndomo[0])
simojimo2=int(joukyuukokuminndomo[1])
joukyuukokuminn=joukyuukokuminn2
simojimo=simojimo2

while joukyuukokuminn%simojimo!=0:
  if joukyuukokuminn>simojimo:
    joukyuukokuminn=joukyuukokuminn-simojimo
  elif joukyuukokuminn<simojimo:
    simojimo=simojimo-joukyuukokuminn

if joukyuukokuminn>=simojimo:
  print(int(joukyuukokuminn2*simojimo2/simojimo))
elif joukyuukokuminn<simojimo:
  print(int(joukyuukokuminn2*simojimo2/joukyuukokuminn))


Measured memory_bytes: 3060
def judge(N):
    cnt = 0
    if (N & 1) == 0:
        return False
    for i in range(1, N+1):
        if N % i == 0:
            cnt += 1
    if cnt == 8:
        return True
    else:
        return False

N = int(input())
cnt = 0
for i in range(1, N+1):
    if judge(i):
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define line cerr<<"--------------------\n";
#define see(x) cerr<<x<<" "
#define seeln(x) cerr<<x<<endl
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=200005;
int n,a[N],b[N],vis[N];
void init()
{
	read(n);
	for (int i=1;i<=n;++i)
	{
		read(a[i]);
		vis[a[i]]++;
	}
	for (int i=1;i<=n;++i)
	{
		read(b[i]);
		vis[b[i]]++;
	}
}

void solve()
{
	for (int i=1;i<=n;++i)
	{
		if (vis[a[i]]>n||vis[b[i]]>n)
		{
			printf("No\n");
			return;
		}
	}
	reverse(b+1,b+n+1);
	int flag=0;
	multiset <int> S,T;
	for (int i=1;i<=n;++i)
	{
		if (a[i]==b[i])
		{
			flag=1;
			S.insert(i);
		}
	}
	if (!flag)
	{
		printf("Yes\n");
		for (int i=1;i<=n;++i)
		{
			printf("%d%c",b[i]," \n"[i==n]);
		}
		return;
	}
	int l=*S.begin(),r=*S.rbegin(),x=a[l];
	for (int i=1;i<=n;++i)
	{
		if (a[i]!=x&&b[i]!=x)
		{
			T.insert(i);
		}
	}
	for (int i=l;i<=r;++i)
	{
		int x=*T.begin();
		T.erase(T.begin());
		swap(b[x],b[i]);
	}
	printf("Yes\n");
	for (int i=1;i<=n;++i) printf("%d%c",b[i]," \n"[i==n]);
}

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


Measured memory_bytes: 15356
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

typedef pair<LL, LL> P;

P s, t;

LL p3[100];


int findK(const P &p) {
    int k = 0;
    LL mx = max(p.first, p.second);
    while (p3[k] < mx)
        ++k;
    return k;
}

P idp(const P &p, int k) {
    if (k == 0)
        return p;
    else {
        return P(p.first / p3[k-1] % 3, p.second / p3[k-1] % 3);
    }
}

LL dis(const P &a, const P &b) {
    return llabs(a.first - b.first) + llabs(a.second - b.second);
}

P basep(const P &p, int k) {
    return P(p.first / p3[k] * p3[k], p.second / p3[k] * p3[k]);
}

int main(int argc, char const *argv[]) {
    // code
    p3[0] = 1;
    for (int i=1; i<=30; ++i)
        p3[i] = p3[i-1] * 3;
    // dbg(p3[30]);
    int tt; scanf("%d", &tt);
    for (int kk=0; kk<tt; ++kk) {
        // cin >> s.first >> s.second >> t.first >> t.second;
        scanf("%lld%lld%lld%lld", &s.first, &s.second, &t.first, &t.second);
        if (s == t) {
            puts("0");
            continue;
        }
        --s.first; --t.first;
        --s.second; --t.second;
        if (llabs(s.first - t.first) < llabs(s.second - t.second)) {
            swap(s.first, s.second);
            swap(t.first, t.second);
        }
        if (s.first > t.first)
            swap(s, t);
        // int k = max(findK(s), findK(t));


        // LL ans = dis(s, t);
        // P ids = idp(s, k), idt = idp(t, k);
        // while ()

        LL ans = dis(s, t);
        // dbg(s.first, s.second, t.first, t.second);
        for (int k=30; k>=1; --k) {
            P ids = idp(s, k), idt = idp(t, k);
            if (basep(s, k-1) == basep(t, k-1))
                continue;
            dbg(ids.first, ids.second, idt.first, idt.second, k);
            if (ids.second == 1 && (ids.first == 0 || idt.first == 2 || llabs(s.first - t.first) > p3[k])) {
                // LL l = p3[k-1]-1, r = 2 * p3[k-1];
                // LL sx = s.second % p3[k], st = t.second % p3[k];
                // ans += min(sx + st - 2 * l, 2 * r - sx - st);
                P bp = basep(s, k);
                // dbg(bp.first, bp.second);
                P l(s.first, bp.second + p3[k-1] - 1),
                r(s.first, bp.second + 2 * p3[k-1]);
                ans = min(dis(s, l) + dis(l, t), dis(s, r) + dis(r, t));
                break;
            }
        }


        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
N, K = gets.split.map(&:to_i)
S = gets.chomp

s01 = []

before_c = nil
sp = -1
count0 = 0
S.each_char do |c|
  if c != before_c
    sp += 1
    s01[sp] = {type: c, count: 0}
    before_c = c
    count0 += 1 if c == '0'
  end
  s01[sp][:count] += 1
end
s01.unshift({type: '1', count: 0}) if S[0] == '0'
s01 << {type: '1', count: 0} if S[-1] == '0'

k = [K, count0].min

# 累積和用
s01_sum = [s01[0][:count]]
1.upto(s01.size - 1) do |i|
  s01_sum << s01_sum[i-1] + s01[i][:count]
end

l_max = s01.size - k * 2 - 1
if l_max < 0
  puts S.size
  exit
end

# p s01
# p s01_sum

max = 0
0.upto(l_max) do |l|
  next if l.odd?
  r = l + k * 2
  sum = s01_sum[r] - (l > 0 ? s01_sum[l - 1] : 0)
  # p [l, r, sum, max]
  if sum > max
    max = sum
  end
end

puts max

Measured memory_bytes: 35064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int can[1000001] = {};
int main() {
	int n, m, k; cin >> n >> m >> k;
	rep(i, n + 1) {
		rep(j, m + 1) {
			int b = (n - i)*j + i * (m - j);
			can[b] = 1;
		}
	}
	if (can[k])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int n, x,count=0; cin >> n >> x;
  vector<int> m(n);
  for(int i=0;i<n;i++) {
    cin >> m[i];
  }
  for(int i=0;i<n;i++) {
    x-=m[i];
    count++;
  }
  sort(m.begin(),m.end());
  count+=(x/m[0]);
  cout << count << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

map<ll,ll> pfmp; //各素因数の冪指数の最大値を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void pf(ll N){
  ll n=N;
  if(n<=0) return;
  ll exp;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    exp=0;
    while(n%2==0){
      n/=2;
      exp++;
    }
    if(exp>pfmp[2]) pfmp[2]=exp;
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      exp=0;
      while(n%i==0){
        n/=i;
        exp++;
      }
      if(exp>pfmp[i]) pfmp[i]=exp;
    }
  }
  if(n!=1){
    if(pfmp[n]==0){
      pfv.push_back(n);
      pfmp[n]=1;
    }
  }
  //sort(all(pfv));
}

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

ll modinv(ll a,ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}

int main(){
  int N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N){
    pf(a[i]);
  }
  ll lcm=1;
  rep(i,pfv.size()){
    lcm*=rui(pfv[i],pfmp[pfv[i]]);
    lcm%=mod;
  }
  ll ans=0;
  rep(i,N){
    ans+=lcm*modinv(a[i],mod);
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<list>
#include<vector>
#include<unordered_map>
#define int long long
#define mod 1000000007
using namespace std;

unordered_map<int, int>U;
vector<int>V;
int p(int a, int b) {
	int c = 1;
	while (b > 1) {
		if (b & 1)c = c*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return a*c%mod;
}
vector<int>T;//n-(y-x+1)個からi個とる方法
signed main() {
	int x = 0, y = 0;//重複
	int n; scanf("%lld", &n);
	for (int i = 0; i < n+1; i++) {
		int j; scanf("%lld", &j);
		if (U[j] != 0) {
			y = i;
			x = U[j] - 1;
		}
		U[j] = i + 1;
	}
	int A = n + 1- (y - x + 1);//残りの個数
	T.push_back(0);
	T.push_back(A);
	for (int i = 2; i <= A; i++) {
		T.push_back(T[i - 1] * (A - i + 1) % mod*p(i, mod - 2) % mod);
	}
	printf("%lld\n", n);
	int K = n+1;
	for (int i = 0; i < n - 1; i++) {
		K = K*(n - i) % mod;
		K = K*p(i + 2, mod - 2) % mod;
		//Kは取り方
		//i個取る
		int ans = K;
		if (i + 1 <= A)ans -= T[i + 1];
		while (ans < 0)ans += mod;
		printf("%lld\n", ans);
	}
	puts("1");
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    ll ans = 0;
    int n; cin>>n;
    vector<ll> v(n);
    map<ll,ll> mp;
    for (int i=0; i<n; i++) {
	cin>>v[i];
	mp[v[i]]++;
    }

    vector<ll> side;
    for (auto p: mp) {
	if (p.second>=4) {
	    ans = max(ans, p.first*p.first);
	}
	if (p.second>=2) {
	    side.push_back(p.first);
	}
    }

    sort(side.rbegin(), side.rend());

    if ((int)side.size() >= 2) {
	ans = max(ans, side[0]*side[1]);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 7296