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

using namespace std;

typedef long long li;

int main() {
    li k, n;
    cin >> k >> n;
    vector<li> ans;
    if (k == 1) {
        li len = (n + 1) / 2;
        for (int i = 0; i < len; ++i) {
            ans.push_back(1);
        }
    } else if (k % 2 == 0) {
        ans.push_back(k / 2);
        li len = n - 1;
        for (int i = 0; i < len; ++i) {
            ans.push_back(k);
        }
    } else {
        li len = n;
        for (int j = 0; j < len; ++j) {
            ans.push_back(k / 2 + 1);
        }

        li shift = n / 2;
        for (int i = 0; i < shift; ++i) {
            li first_nzp = -1;
            for (int j = n - 1; j >= 0; --j) {
                if (ans[j] != 0) {
                    first_nzp = j;
                    break;
                }
            }
            if (ans[first_nzp] == 1) {
                for (int j = first_nzp + 1; j < n; ++j) {
                    ans[j] = 0;
                }
            } else {
                for (int j = first_nzp + 1; j < n; ++j) {
                    ans[j] = k;
                }
            }
            ans[first_nzp] -= 1;
        }
    }

    for (int j = 0; j < ans.size(); ++j) {
        if (ans[j] == 0) {
            cout << endl;
            break;
        }
        cout << ans[j];
        if (j + 1 == ans.size()) {
            cout << endl;
        } else if (ans[j + 1] != 0) {
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

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



Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);

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


int main()
{
#ifndef RICARDO
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> sum(n);
    if (s[0]=='W') sum[0]=1;
    for(int i=1; i<n;++i)
    {
        sum[i]=sum[i-1];
        if (s[i]=='W') sum[i]++;
    }
    int minn = 1e6;
    int dem=0;
    for(int i=n-1; i>0; --i)
    {
        minn = min(minn,sum[i-1]+dem);
        if (s[i]=='E') dem++;
    }
    minn = min(minn,dem);
    cout << minn;
    return 0;
}



Measured memory_bytes: 1812
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
typedef long long ll;
const int mod=1e9+7;
const int N=86400;
int main()
{
    int r,g;
    while(~scanf("%d%d",&r,&g))
    {
        int ans=2*g-r;
        printf("%d\n",ans);
    }
    return 0;
}
/**
2 2
86400 86398
2 86400
0 86400
**/


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cnt[a]++;
    cnt[b]++;
  }
  
  rep(i, n) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,K;
    cin >> N >> K;
    map<int,int> mp;
    rep(i,N){
        int D;
        cin >> D;
        mp[D] = 1;
    }
    for(int i=1;i<200000;i++){
        if(i<N)continue;
        string Snum;
        Snum = to_string(i);
        bool f = true;
        for(int j=0;j<Snum.size();j++){
            if(mp[Snum[j]-'0']==1){
                f = false;
                break;
            }
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
#define ln endl
const int N=1e5+5;
char s[N];
int n,cnt[N],a[N],t[N][2];
int main() {
	scanf("%s",s+1); n=strlen(s+1);
	for( int i=1;i<=n;i++ ) if(s[i]=='L') a[i]=0; else a[i]=1;
	for( int i=1;i<=n;i++ ) 
		if(a[i]==0) t[i][0]=t[i-1][0]-1;
	for( int i=n;i;i-- ) 
		if(a[i]==1) t[i][1]=t[i+1][1]+1;
	for( int i=1;i<=n;i++ ) {
		if(t[i][0]) {
			int pos=i+t[i][0];
			if(abs(t[i][0])&1) cnt[pos+1]++;
			else cnt[pos]++;
		}
		if(t[i][1]) {
			int pos=i+t[i][1];
			if(t[i][1]&1) cnt[pos-1]++;
			else cnt[pos]++;
		}
	}
	for( int i=1;i<=n;i++ )
		cout<<cnt[i]<<" ";
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		if(a != b && b != c && c != a) {
			System.out.println("No");
		} else if(a == b && b == c) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}

}


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

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

  int a, b, c;
  cin >> a >> b >> c;

  vector<bool> num(101, false);

  num[a] = true;
  num[b] = true;
  num[c] = true;

  int ans = count(num.begin(), num.end(), true);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    string s,t;
    cin >> s >> t;
    ll cnt=0;
    for(int i=0;i<s.size();i++)
    if(s[i]!=t[i])
    cnt++;
    
    cout << cnt << endl;

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

	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,x;
  cin >> N >> x;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  vl sum(N+1,0);
  rep(i,N) {
    sum[i+1] = sum[i] + A[i];
  }
  int ans = lower_bound(rng(sum),x) - sum.begin();
  if(ans == N+1) {
    ans -= 2;
  } else if(sum[ans] > x) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

bool inside(ll h,ll w,ll y,ll x) {
    return (0 <= y && y < h && 0 <= x && x < w);
}

int main() {
    ll h, w, m;
    cin >> h >> w >> m;

    vector<pair<ll, ll>> bomb(m);
    vector<ll> r(h);
    vector<ll> c(w);
    for (int i = 0; i < m; i++) {
        ll hi, wi;
        cin >> hi >> wi;
        hi--; wi--;
        bomb[i] = {hi, wi};
        r[hi]++;
        c[wi]++;
    }

    ll maxr = 0;
    ll maxc = 0;
    for (int i = 0; i < h; i++) maxr = max(maxr, r[i]);
    for (int i = 0; i < w; i++) maxc = max(maxc, c[i]);

    ll maxrcnt = 0;
    ll maxccnt = 0; 
    for (int i = 0; i < h; i++) {
        if (r[i] == maxr) maxrcnt++;
    }
    for (int i = 0; i < w; i++) {
        if (c[i] == maxc) maxccnt++;
    }

    ll mcnt = 0;
    for (int i = 0; i < m; i++) {
        if (r[bomb[i].first] == maxr && c[bomb[i].second] == maxc) {
            mcnt++;
        }
    }

    if (mcnt == maxrcnt*maxccnt) cout << maxr + maxc - 1 << endl;
    else cout << maxr + maxc << endl;
}

Measured memory_bytes: 12740
#include<bits/stdc++.h>
using namespace std;
int main(){
  int age,value;
    cin>>age>>value;
  if(age>12){
    cout<<value<<endl;
  }
  else if(age>=6 && age <=12){
    cout<<value/2<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}

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

int main(){
	int N;
	double v[1010];
	cin >> N;
	
	for(int i=0; i<N; i++){
		cin >> v[i];
	}
	
	sort(v,&v[N]);
	
	for(int i=0; i<N-1; i++){
		v[i+1]=(v[i]+v[i+1])/2;
	}
	
	cout << v[N-1] << endl;

	return 0;
}	

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

int main() {
    int W = 3;
    vector<vector<int>> A(W, vector<int>(W));
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    vector<vector<bool>> open(W, vector<bool>(W, false));
    for (int i = 0; i < N; i++) {
        for (int h = 0; h < W; h++) {
            for (int w = 0; w < W; w++) {
                if (A[h][w] == b[i]) {
                    open[h][w] = true;
                }
            }
        }
    }

    for (int h = 0; h < W; h++) {
        bool ok = true;
        for (int w = 0; w < W; w++) {
            ok = ok && open[h][w];
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int w = 0; w < W; w++) {
        bool ok = true;
        for (int h = 0; h < W; h++) {
            ok = ok && open[h][w];
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (open[0][0] && open[1][1] && open[2][2]) {
        cout << "Yes" << endl;
        return 0;
    } else if (open[2][0] && open[1][1] && open[0][2]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
#define rep(i,n)  for(int i = 0; i < n ; i++)

vector<vector<char>> maps (500 ,vector<char>(500));
static bool reached[500][500];
bool isGoal = false;

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

	long d = c - a - b;
	if (d * d > 4 * a * b && d > 0) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#define inf 1000000000

using namespace std;

struct edge{
	int to, cap, cost, rev;
	edge(){}
	edge(int a, int b, int c, int d){
		to = a, cap = b, cost = c, rev = d;
	}
};

struct ope{
	int i, j, type;
	ope(int a, int b, int c){
		i = a, j = b, type = c;
	}
};

int n;
int W[105][105], E[105][105];
char F[105][105];

int cost[105][105];
int S, T;
vector<edge> G[205];
int dist[205];
int prevv[205], preve[205];
vector<ope> vec;

void BellmanFord()
{
	for(int i = 0; i <= T; i++) dist[i] = inf;
	dist[S] = 0, prevv[S] = -1;
	
	bool update = true;
	while(update){
		update = false;
		for(int i = 0; i <= T; i++){
			for(int j = 0; j < G[i].size(); j++){
				if(G[i][j].cap == 0) continue;
				if(dist[G[i][j].to] > dist[i] + G[i][j].cost){
					dist[G[i][j].to] = dist[i] + G[i][j].cost;
					prevv[G[i][j].to] = i;
					preve[G[i][j].to] = j;
					update = true;
				}
			}
		}
	}
}

void add_edge(int from, int to, int cap, int cost)
{
	G[from].push_back( edge(to, cap, cost, G[to].size()) );
	G[to].push_back( edge(from, 0, -cost, G[from].size()-1) );
}

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> W[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> E[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> F[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int sum = 0;
			for(int k = 0; k < n; k++){
				if(j == k && F[i][k] == '.') sum += W[i][k];
				if(j != k && F[i][k] == 'o') sum += E[i][k];
			}
			cost[i][j] = sum;
		}
	}
	
	S = 2*n, T = 2*n+1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			add_edge(i, j+n, 1, cost[i][j]);
		}
	}
	for(int i = 0; i < n; i++) add_edge(S, i, 1, 0);
	for(int i = 0; i < n; i++) add_edge(i+n, T, 1, 0);
	
	int f = n, ans = 0;
	while(f > 0){
		BellmanFord();
		
		int p = T, flow = f;
		while(prevv[p] != -1){
			flow = min(flow, G[prevv[p]][preve[p]].cap);
			p = prevv[p];
		}
		
		p = T;
		while(prevv[p] != -1){
			G[prevv[p]][preve[p]].cap -= flow;
			G[p][G[prevv[p]][preve[p]].rev].cap += flow;
			p = prevv[p];
		}
		f -= flow;
		ans += dist[T] * flow;
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < G[i].size(); j++){
			if(G[i][j].cap > 0) continue;
			int J = G[i][j].to - n;
			for(int k = 0; k < n; k++){
				if(J == k && F[i][k] == '.') vec.push_back( ope(i, k, 0) );
				if(J != k && F[i][k] == 'o') vec.push_back( ope(i, k, 1) );
			}
		}
	}
	
	cout << ans << endl;
	cout << vec.size() << endl;
	for(int i = 0; i < vec.size(); i++){
		cout << vec[i].i+1 << " " << vec[i].j+1 << " ";
		if(vec[i].type) cout << "erase" << endl;
		else cout << "write" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3544
a,b,c = gets.chomp.split(" ").map{|str| str.to_i}.sort

#この時点でa<=b<=cである
#b+c>b>=aなのでa=b+cにはならない
#c+a>c>=bなのでb=c+aにはならない
#c=a+bの可能性だけを考えればよい

if c==a+b then
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 30000

signed main() {
    int n;
    cin >> n;
    int p[n];
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    int a[n], b[n];
    rep(i, n) {
        a[i] = 1 + MAX * i;
        b[i] = 1 + MAX * (n - 1 - i);
    }
    rep(i, n) {
        a[p[i]] += i;
    }
    rep(i, n) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    rep(i, n) {
        if (i) cout << " ";
        cout << b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3800
#include<stdio.h>
#include<string.h>
int x,y,dp[20][15],m[20][15],i,j,k,t,r;
int main()
{
	for(;scanf("%d%d",&x,&y),x;)
	{
		memset(dp,0,sizeof(dp));
		memset(m,0,sizeof(m));
		for(i=0;i<y;i++)
			for(j=0;j<x;j++)
				scanf("%d",&m[i][j]);
		for(i=0;i<x;i++)
			if(!m[0][i])
				dp[0][i]=1;
		for(i=0;i<y-1;i++)
			for(j=0;j<x;j++)
			{
				if(m[i][j]==0)
				{
					if(m[i+1][j]!=1)
						dp[i+1][j]+=dp[i][j];
					if(j>0&&m[i+1][j-1]==0)
						dp[i+1][j-1]+=dp[i][j];
					if(j<x-1&&m[i+1][j+1]==0)
						dp[i+1][j+1]+=dp[i][j];
				}
				else if(m[i][j]==1)
					dp[i][j]=0;
				else
					if(m[i+2][j]!=1)
						dp[i+2][j]+=dp[i][j];
			}
		for(i=r=0;i<x;i++)
			r+=dp[y-1][i]+dp[y][i]+dp[y+1][i];
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    ll n; cin >> n;
    ll used = 0;
    ll total = 0;
    string res = "";
    for (ll x = 26;; x *= 26) {
        total += x;
        res += "a";
        if (total >= n) {
            n -= used;
            n--;
            break;
        }
        used += x;
    }
    ll need = 1;
    for (int i = SZ(res) - 1; i >= 0; i--, need *= 26) {
        res[i] = (char) ('a' + (n / need) % 26);
    }
    cout << res << "\n";
}


Measured memory_bytes: 3600
#!/usr/bin/ruby
def x(s)s.size>1&&s[0..0]=='X'end
while(l=gets)
l=~/([0-9X]+)\+([0-9X]+)=([0-9X]+)/
a=$1+'+'+$2+'=='+$3
puts 'NA' if ((x($1)||x($2)||x($3))?1:0).step(9){|i|if eval(a.gsub('X',i.to_s)) then p i;break end}end

Measured memory_bytes: 5128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
        int n = sc.nextInt();
        int s = sc.nextInt();
        if(n == 0 && s == 0) break;
        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        int ans = 0;
        for(int i = 0; i<(Math.pow(2,10)); i++){
            int sum = 0;
            int time = 0;
            for(int j=0; j<10; j++){
                if((1&i>>j) == 1) {
                    sum += a[j];
                    time++;
                }
            }
            if(sum == s && time == n) ans++;
        }
        System.out.println(ans);

        }
        sc.close();
    }
}


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

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

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

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

    set<int> v;
    int a, b, c;
    cin >> a >> b >> c;
    v.insert(a);
    v.insert(b);
    v.insert(c);
    cout << v.size() << endl;
}


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

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

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string a, b;
    cin >> a >> b;

    b.pop_back();

    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3600
s=input()
if "SUN" in s:
    print("7")
elif "MON" in s:
    print("6")
elif "TUE" in s:
    print("5")
elif "WED" in s:
    print("4")
elif "THU" in s:
    print("3")
elif "FRI" in s:
    print("2")
else:
    print("1")

Measured memory_bytes: 2940
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split
end
 
N = ary[0][0]
M = ary[0][1]
ary.delete_at(0)
ipai = Array.new
ary.map{|item|
    item.delete_at(0)
}
ary.each{|item|
    item.each{|m|
        ipai.push(m)}
}
kai = 0
ipai.map!(&:to_i)
M.to_i.times{|m|
    if N.to_i == ipai.count(m.to_i+1) then
        kai = kai + 1
    end
}
print kai

Measured memory_bytes: 3836
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
 
    int gu =K/2;
    if(K%2==0){
		System.out.println(gu*gu);
    }else{
        System.out.println(gu*(gu+1));
    }
}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    bool OK=true;
    for(int i=0; i<N; i++){
        cin>>A[i];
        if(A[i]%2==0){
            if(A[i]%3==0||A[i]%5==0){
                continue;
            }
            else{
                OK=false;
                break;
            }
        }
    }
    cout<<(OK?"APPROVED":"DENIED")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define K 10000  //A[i]最大値

int *countingSort(int*, int); //入力された配列、ソート後の配列、入力の要素数

main(){
  int *arrA, *arrB;
  int n, i;

  scanf("%d", &n);
  arrA = (int *)malloc(sizeof(int)*n);
  for(i=0; i<n; i++) scanf("%d", arrA+i);

  arrB = countingSort(arrA, n);

  for(i=0; i<n-1; i++) printf("%d ", arrB[i]);
  printf("%d\n", arrB[i]);

  return 0;
}

int *countingSort(int *arrA, int n){
  int *arrB, arrC[K+1], i;
  arrB = malloc(sizeof(int)*n);

  arrC[0] = -1;
  for(i=1; i<=K; i++) arrC[i] = 0;
  
  for(i=0; i<n; i++){
    arrC[arrA[i]]++;
  }
  
  for(i=1; i<=K; i++){
    arrC[i] = arrC[i] + arrC[i-1];
  }

  /*  for(i=0; i<=K; i++){
    printf("arrC[%d] = %d\n", i, arrC[i]);
    }*/
  
  for(i=n-1; i>=0; i--){
    arrB[arrC[arrA[i]]] = arrA[i];
    arrC[arrA[i]]--;
  }

  return arrB;
}

Measured memory_bytes: 16268
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
#define PI 3.141592

double diffx(int d,int r){
  return d*cos(-1*(r*PI/180.0-PI/2));
}

double diffy(int d,int r){
  return d*sin(-1*(r*PI/180.0-PI/2));
}

int main(){
  double x=0,y=0;
  int r=0;
  int move,rr;
  while(true){
    scanf("%d,%d",&move,&rr);
    if(move==0){
      cout<<(int)x<<endl<<(int)y<<endl;  
      return 0;
    }
    x+=diffx(move,r);
    y+=diffy(move,r);
    //  cout<<diffx(move,r)<<' '<<diffy(move,r)<<endl;
    r+=rr;
    // cout<<'('<<x<<','<<y<<')'<<endl;  
  } 

}

Measured memory_bytes: 1252
/* ****GT_18**** */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define INF			1000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
using namespace __gnu_pbds;

#define N  100005

ll n,m;
vi a[N];
ll sub[N];
ll dad[N];

void dfs(ll node, ll par){
	ll s=sz(a[node]);
	ll dp1[s];
	ll cur=1;
	for(ll i=0;i<s;i++){
		ll ch = a[node][i];
		if(ch==par){dp1[i]=cur;continue;}
		dfs(ch,node);
		dp1[i]=(cur*(sub[ch]+1))%m;
		cur=(cur*(sub[ch]+1))%m;
	}
	sub[node]=cur;
	cur=1;
	// cerr<<"node: "<<node<<" ";
	// rep(i,0,s){
	// 	ll ch = a[node][i];
	// 	if(ch==par)continue;
	// 	cerr<<dp1[i]<<" ";
	// }
	// cerr<<endl;
	for(ll i=s-1;i>0;i--){
		ll ch=a[node][i];
		if(ch==par)continue;
		dad[ch]=(cur*dp1[i-1])%m;
		cur=(cur*(sub[ch]+1))%m;
		// cerr<<"node:"<<node<<" ch:"<<ch<<" dad:"<<dad[ch]<<endl;
	}
	if(a[node][0]!=par){
		dad[a[node][0]]=cur;
		// cerr<<"node:"<<dad[a[node][0]]<<endl;
	}
}

void dfs2(ll node, ll par){
	dad[node]=(dad[node]*(dad[par]+1))%m;
	for(auto i:a[node]){
		if(i==par)continue;
		dfs2(i,node);
	}
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		cin>>n>>m;
		rep(i,0,n-1){
			ll x,y;
			cin>>x>>y;
			a[x].pb(y);
			a[y].pb(x);
		}
		if(n==1){
			cout<<n%m<<endl;
			return 0;
		}
		dfs(1,0);
		dfs2(1,0);
		// rep(i,1,n+1){
		// 	cerr<<sub[i]<<" "<<dad[i]<<endl;
		// }
		rep(i,1,n+1){
			cout<<(sub[i]*(dad[i]+1))%m<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 20964
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <climits>
#include <deque>
#include <map>
#include <deque>
#include <iomanip>
#include <cmath>
#include <functional>
#include <set>
#include <list>
#include <bitset>
#include <stack>
#include <stdio.h>
#define endl '\n'
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
typedef pair<ll,ll> pll;
int main()
{
    /*
for reading from input.txt and writing on output.txt
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
*/
    cin.sync_with_stdio(false);
    ll a,b;cin>>a>>b;
    cout<<(6-(a+b))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

int main() {
    ll n,x,y;
    cin >> n >> x >> y;
    --x,--y;
    vector<vector<int>> dist(n, vector<int>(n, -1));
    for (int s = 0; s < n; ++s) {
        queue<int> que;
        que.push(s);
        dist[s][s] = 0;
        while (!que.empty()) {
            auto v = que.front(); que.pop();
            vector<int> nvs;
            if (v > 0) nvs.push_back(v-1);
            if (v < n-1) nvs.push_back(v+1);
            if (v == x) nvs.push_back(y);
            if (v == y) nvs.push_back(x);
            for (auto nv : nvs) {
                if (dist[s][nv] == -1) {
                    dist[s][nv] = dist[s][v] + 1;
                    que.push(nv);
                }
            }
        }
    }
    vector<ll> res(n,0);
    rep(i,n){
        repp(j,i+1,n)res[dist[i][j]]++;
    }
    repp(i,1,n)cout << res[i] << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N,K;
    int res=0;
    vector<int> P;
    cin >> N >> K;
    P.resize(N);
    for (int i =0;i<N;i++){
        cin >> P.at(i);
    }
    sort(P.begin(),P.end());
    for(int i=0;i<K;i++){
        res+=P[i];
    }
    cout<<res;
}

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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main() {
	int N, M;
	cin >> N >> M;
	int l = 1, r = N;
	for (int i = 0; i < M; ++i) {
		int li, ri;
		cin >> li >> ri;
		l = max(l, li);
		r = min(r, ri);
	}
	if (r - l + 1 <= 0) {
		cout << 0 << endl;
	}
	else {
		cout << r - l + 1 << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            char[] K = Console.ReadLine().ToCharArray();
            K[A[1] - 1] = char.ToLower(K[A[1] - 1]);
            Console.WriteLine($"{new string(K)}");
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++) 
#define _For(i,a,b) for(int i=a;i>=b;i--)
#define LL long long 
const int N = 105;
LL t,n,m,ans;
int a[N][N];
vector<int> v;
int main(){
//	freopen("2.txt","r",stdin);
	cin>>n>>m;
	if(n>2&&m>2)
	cout<<n*m-2*n-2*(m-2)<<endl;
	else{
		if(m<n)
		t=n,n=m,m=t;
		if(n==1&&m>2){
			cout<<m-2<<endl;
			exit(0);
		}
		else if(n==2&&m>=2){
			cout<<0<<endl;
			exit(0);
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				a[i][j]++,a[i-1][j-1]++,a[i-1][j+1]++,a[i+1][j+1]++,
				a[i-1][j]++,a[i][j+1]++,a[i][j-1]++,a[i+1][j]++,a[i+1][j-1]++; 
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(a[i][j]%2==1)
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int gcd(int x,int y){
    if(y==0) return x;
    else return gcd(y,x%y);
}

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int g=gcd(a,b);
    int ctr=0;
    for(int i=g; i>0;i--){
        if(g%i==0) ctr++;
        if(ctr==k) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//B - Five Dishes
int main(void){
    int cooktime[5];
    int last=5;
    int min=10;
    for (int i = 0; i < 5; i++) {
        std::cin >> cooktime[i];
        int tmp=cooktime[i]%10;
        if(tmp>0 && tmp<min){
            min=tmp;
            last=i;
        }
    }
    int ans=0;
    for (int i = 0; i < 5; i++) {
        if(i==last){
            ans+=cooktime[i];
        }else{
            if(cooktime[i]%10==0)
                ans+=cooktime[i];
            else
                ans+=(cooktime[i]/10+1)*10;
        }
    }
    std::cout << ans << std::endl;
    
}


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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	ll ans=0;
	rep(i,n)rep(j,i){
		int s = a[i]+a[j];
		int k = lower_bound(a.begin(),a.end(),s)-a.begin();
		ans += max(k-i-1,0);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char s[105];
	scanf("%s",s);
	int n = strlen(s);
	printf("%c%d%c\n",s[0],n-2,s[n - 1]);
	return 0;
	}

Measured memory_bytes: 128
#include<stdio.h>
main()
{
  int i,j,n,q,cnt=0;
  int left,right,mid;
  int S[100000],T[50000];
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(j = 0; j < q; j++) {
    scanf("%d",&T[j]);
    left = 0;
    right = n;
    while(left < right) {
      mid = (left + right)/2;
      if(T[j] == S[mid]) {
	cnt++;
	break;
      }
      if(T[j] > S[mid]) {
	left = mid + 1;
      }
      else if(T[j] < S[mid]) {
	right = mid;
      }
    }
  }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int sum=0;
    string n;
    cin >> n;
    for(int i=0; i<n.length(); i++){
        int num = n[i] - '0';
        sum += num;
    }
    int num = stoi(n);
    if(int(num)%sum == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
/*
    Flowers, wake up like the sea!
*/
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x7fffffff
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
typedef vector<int> VI;
typedef map<int,int> MII;
const int N = 2e5 + 10, MOD = 7+1e9;
int n, q, s, t, x, ans[N];
multiset<int> se;

struct TEvent
{
    int tim, typ, ind;

    TEvent(int _tim = 0, int _typ = 0, int _ind = 0)
    {
        tim = _tim; typ = _typ; ind = _ind;
    }

    bool operator<(const TEvent &oth) const
    {
        return tim < oth.tim || (tim == oth.tim && typ < oth.typ);
    }
};
vector<TEvent> ve;

int main()
{
#ifdef YUUKILP
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
    {
        cin >> s >> t >> x;
        ve.push_back(TEvent(s - x, 1, x));
        ve.push_back(TEvent(t - x, 2, x));
    }
    for(int i = 1; i <= q; i++)
    {
        cin >> x;
        ve.push_back(TEvent(x, 3, i));
    }
    sort(ve.begin(), ve.end());
    for(TEvent &v : ve)
    {
        if(v.typ == 1)
            se.insert(v.ind);
        else if(v.typ == 2)
            se.erase(se.find(v.ind));
        else
        {
            if(se.empty()) ans[v.ind] = -1;
            else ans[v.ind] = *se.begin();
        }
    }
    for(int i = 1; i <= q; i++)
        cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 19304
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

bool check(ll n, ll k) {
	while(n >= k) {
		if(n % k == 0) n /= k;
		else n %= k;
	}
	if(n == 1) return true;
	else return false;
}

int main() {
	ll n;
	cin >> n;
	ll x = n;
	map<ll, ll> mp;
	for(ll i = 2; i * i <= x; i++) {
		while(x % i == 0) {
			mp[i]++;
			x /= i;
		}
	}
	if(x > 1) mp[x]++;
	vll a(1, 1);
	for(auto i = mp.begin(); i != mp.end(); i++) {
		ll base = 1;
		int size = a.size();
		for(int j = 1; j <= i->second; j++) {
			base *= i->first;
			for(int k = 0; k < size; k++) {
				a.push_back(a[k] * base);
			}
		}
	}
//	show(a, a.size());
	set<ll> s;
	for(auto i: a) s.insert(i);
	mp.clear();
	a.clear();
	x = n-1;
	for(ll i = 2; i * i <= x; i++) {
		while(x % i == 0) {
			mp[i]++;
			x /= i;
		}
	}
	if(x > 1) mp[x]++;
	a.push_back(1);
	for(auto i = mp.begin(); i != mp.end(); i++) {
		ll base = 1;
		int size = a.size();
		for(int j = 1; j <= i->second; j++) {
			base *= i->first;
			for(int k = 0; k < size; k++) {
				a.push_back(a[k] * base);
			}
		}
	}
//	show(a, a.size());
	for(auto i: a) s.insert(i);
	s.erase(1);
	int ans = 0;
	for(auto i = s.begin(); i != s.end(); i++) {
//		cout << *i << ' ';
		if(check(n, *i)) ans++;
	}
//	cout << endl;
	cout << ans << endl;
}


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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

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

	int n, d;
	cin >> n >> d;
	int r = n+d;
	int l = n-d;
	int x = r-l+1;
	cout << (n+x-1) / x << "\n";

	return 0;
}


Measured memory_bytes: 256
main = do
  n <- getLine
  a <- map read . words <$> getLine
  putStrLn . show $ solve a



solve :: [Integer] -> Integer
solve xs =
  let absed = map abs xs
      minabs = minimum absed
      m = minusCnt xs
      z = zeroCnt xs
  in if m `mod` 2 == 0 || (m+z) `mod` 2 == 0 then
    sum absed
  else
    sum absed - (2*minabs)

minusCnt :: [Integer] -> Int
minusCnt = length . filter (\x -> x < 0)

zeroCnt :: [Integer] -> Int
zeroCnt = length . filter (\x -> x == 0)


Measured memory_bytes: 39548
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>btn(N,0);
  
  for(int i=0;i<N;i++){
    cin >> btn[i];
  }
  
  int now_btn = 0;
  int ans = 0;
  
  while(1){
    now_btn = btn[now_btn] - 1;
    ans++;
    if(now_btn == 1){
      break;
    }
    else if(now_btn == 0){
      ans = -1;
      break;
    }
    else if(ans > N){
      ans = -1;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
def sequence(N: int, A: list) -> int:
    op1, op2 = 0, 0
    s1, s2 = 0, 0

    for i, a in enumerate(A):
        s1, s2 = s1 + a, s2 + a

        if i % 2 > 0:  # odd
            if s1 <= 0:
                op1 += abs(s1) + 1
                s1 += abs(s1) + 1
            if s2 >= 0:
                op2 += abs(s2) + 1
                s2 -= abs(s2) + 1
        else:  # even
            if s1 >= 0:
                op1 += abs(s1) + 1
                s1 -= abs(s1) + 1
            if s2 <= 0:
                op2 += abs(s2) + 1
                s2 += abs(s2) + 1

    return min(op1, op2)


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = sequence(N, A)
    print(ans)


Measured memory_bytes: 14468
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()

def main():
    n = input()
    val = 0
    for c in n:
        val += int(c)
    if val % 9 == 0:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long unsigned int ll;

int main() {
  long long N, M;
  cin >> N >> M;

  vector<long long> candidates;
  for (long long i = 1LL; i <= sqrt(M); ++i) {
    if (M % i == 0) {
      candidates.push_back(i);
      if (M / i != i) candidates.push_back(M / i);
    }
  }

  long long ans = 0;
  for (int i = 0; i < (int)candidates.size(); ++i) {
    if (candidates[i] * N <= M) {
      ans = max(ans, candidates[i]);
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  int X[N], Y[N];
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    Y[i] = X[i];
  }
  
  sort(Y, Y+N);
  
  int middle1 = Y[N/2 -1], middle2 = Y[N/2];
  
  for (int i = 0; i < N; i++) {
    if (X[i] <= Y[N/2-1]) {
      cout << middle2 << endl;
    } else {
      cout << middle1 << endl;
    }
  }
  
}

Measured memory_bytes: 5144
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

int N, K, L;
int A[200005];

bool f(int x) {
    // x以下の数がK個以上ある連続区間の数を調べる
    int ret = 0;
    int cnt = 0;
    int r = -1;
    for (int l = 0; l < N; l++) {
        if (l >= 1 && A[l-1] <= x) cnt--;
        bool flag = false;

        while (r < 0 || cnt < K) {
            r++;
            if (A[r] <= x) cnt++;
            if (r >= N) {
                flag = true;
                break;
            }
        }

        if (flag) break;
        ret += N - r;
    }

    return ret >= L;
}

signed main() {
    cin >> N >> K >> L;
    for (int i = 0; i < N; i++) cin >> A[i];

    int lb = 0;
    int ub = INF;
    while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if (f(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;
}


Measured memory_bytes: 4668
#include <iostream>

using namespace std;

#define ll long long int

ll yukurid(ll a, ll b){
  //cout << "a/b=" << a << "/" << b << endl;
  if(b==0) return a;
  return yukurid(b, a%b);
}

int main(){
  ll A,B;
  cin >> A >> B;
  //cout << yukurid(A,B) << endl;
  ll kouyaku = yukurid(A,B);
  cout << A*B/kouyaku << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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


int main(){
    int N, ans;
    cin >> N;
    for(int i = 0; pow(2, i) <= N; i++){
        ans = pow(2, i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[1000010],b[1000010],n;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int jyz,wzl;
		cin>>jyz>>wzl;
		if (jyz==wzl) a[i]=1;
		else a[i]=0;
	}
	for (int i=1;i<=n-2;i++) if (a[i]*a[i+1]*a[i+2]==1)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        int result = 0;

        for(int i = 0; i < input.length(); i++){
            if(input.charAt(i) == '1'){
                result++;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21716
// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／								AC		AC		AC		AC
//    │　Z ＿,＜　／　　 /`ヽ						AC		AC		AC		AC
//    │　　　　　ヽ　　 /　　〉					AC		AC		AC		AC
// 　Y　　　　　`　 /　　/  /						AC		AC		AC		AC
// 　亻●　.　●　　〈　/　/						AC		AC		AC		AC
// 　()　 へ　　　　|　＼〈							AC		AC		AC		AC
// 　　>- ._　 ィ　 │ ／／							AC		AC		AC		AC
// 　 / へ　　 /　/＜| ＼＼							AC		AC		AC		AC
// 　 ヽ_/　　(_／　 │／／							AC		AC		AC		AC
// 　　 7　　　　　　　|／							AC		AC		AC		AC
// 　　 ＞―r￣￣`-―＿/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n,m;
vector<int> v[1010];
int vis[1010];
vector<int> path;
int indeg[1010],outdeg[1010];
bool edges[1010][1010];

bool OK()
{
	memset(indeg,0,sizeof(indeg));
	memset(outdeg,0,sizeof(outdeg));
	
	for(int i=0;i<path.size();i++)for(int j=0;j<path.size();j++)
	{
		if(indeg[path[i]]>1||outdeg[path[j]]>1)return 0;
		
		if(edges[path[i]][path[j]])indeg[path[i]]++,outdeg[path[j]]++;
	}
	
	for(int i=0;i<path.size();i++)if(indeg[path[i]]!=1||outdeg[path[i]]!=1)return 0;
	
	return 1;
}

void pprint()
{
	if(!OK())return;
	
	cout<<path.size()<<endl;for(int i=0;i<path.size();i++)cout<<path[i]<<endl;
	
	exit(0);
}

void DFS(int x)
{
	path.pb(x);
	vis[x]=2;
	
	for(int i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==0)DFS(v[x][i]);
		if(vis[v[x][i]]==2)pprint();
	}
	
	path.pop_back();
	vis[x]=1;
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>m;
	
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		
		v[x].pb(y);
		
		edges[x][y]=1;
	}
	
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		path.clear();
		
		if(!vis[i])DFS(i);
	}
	
	cout<<-1;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


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

int main() {
	int n;
	cin >> n;
	string word[n];
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> word[i];
		if (mp[word[i]]) {
			cout << "No" << endl;
			return 0;
		}
		else mp[word[i]]++;
	}
	for (int i = 1; i < n; i++) {
		if (word[i][0] != word[i - 1][word[i - 1].size() - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%s", $t);
$arr1 = str_split($s);
$arr2 = str_split($t); 
$n = strlen($s);
$ans = 'Yes';
for($i=0;$i<$n;++$i){
  if($arr1[$i] != $arr2[$i]){   
    $ans ='No';
    break;
  }
}
echo $ans;
?>

Measured memory_bytes: 16128
n = gets.to_i

if n < 10
  puts n
  exit
end

if n == 10
  puts 9
  exit
end

ans = 9
add = 3
head = ''

(11..n).each do |i|
  is = i.to_s
  if head && is[0] != head
    add = 3    
  end
  head = is[0]  
  next if is[-1] == '0'

  d = is.size

  if is[0] == is[-1]
    # puts add
    ans += ("2" * (d-2)).to_i
    ans += add
    add += 2
  elsif i > is.reverse.to_i
    ans += ("2" * (d-1)).to_i
  else
    ans += ("2" * (d-2)).to_i
  end
  # if is[0] == is[-1]
  #   # puts add
  #   ans += add
  #   add += 2
  # end
end
puts ans

# list = []
# (1..n).each do |i|
#   is = i.to_s
#   (1..n).each do |j|
#     js = j.to_s
#     if is[0] == js[-1] && is[-1] == js[0]
#       list << [i, j]
#     end
#   end
# end

# # puts list.inspect

# puts list.size

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

using namespace std;

void add_elements(vector<int>& steps, int base, int threshold) {
    int element = base;
    while (element <= threshold) {
        steps.push_back(element);
        element *= base;
    }
}

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

    int N;
    cin >> N;

    vector<int> dp(N + 1, N + 1);
    dp[0] = 0;

    vector<int> steps(1, 1);
    add_elements(steps, 6, N);
    add_elements(steps, 9, N);
    sort(steps.begin(), steps.end());

    for (int i = 1; i <= N; i++) {
        for (int step: steps) {
            if(i - step < 0){
                break;
            }
            dp[i] = min(dp[i], dp[i-step] + 1);
        }
    }

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

Measured memory_bytes: 640
#include<iostream>
using namespace std;
const int N=2e5+10;
int n,k;
int d[N];
int hs(int x){
	int f=0;
	while(x>0){
		if(d[x%10]) f=1;
		x/=10;
	}
	if(f) return 0;
	else return 1;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		int x;
		cin>>x;
		d[x]=1;
	}
	for(int i=n;;i++)
		if(hs(i)){
			printf("%d",i);
			break;
		}
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  ll n;
  cin >>n;
  ll a[n];
  ll ans=10010000000;
  rep(i,n){
    cin >> a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  ll b;
  b=(a[(n-1)/2]+a[n/2])/2;
  ll res =0;
  rep(j,n)res+=abs(a[j]-b);
  cout << res << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	char s[100001],ans[60000];
	
	scanf("%s",s);
	
	for(int i=0;s[i]!='\0';i++){
		if(i%2==0){
			ans[i/2]=s[i];
		}
	}
	
	printf("%s\n",ans);
}

Measured memory_bytes: 384