akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    cout<<"ABC"<<n<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRally solver = new CRally();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRally {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] c = in.nextIntArray(N);
            long minsum = Long.MAX_VALUE;
            for (int p = 0; p <= 100; p++) {
                long tot = 0;
                for (int i = 0; i < N; i++) {
                    tot += (c[i] - p) * (c[i] - p);
                }
                minsum = Math.min(tot, minsum);
            }
            out.println(minsum);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

    }
}



Measured memory_bytes: 32576
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,root1,root2,ne1[N],fi1[N],zz1[N],tot,cnt,ne2[N],zz2[N],fi2[N],fi[N];
int zz[N],ne[N],Stack[N],num1[N],num2[N],x,flag[N];
void jb1(int x,int y){
	ne1[++tot]=fi1[x];
	fi1[x]=tot;
	zz1[tot]=y;
}
void jb2(int x,int y){
	ne2[++tot]=fi2[x];
	fi2[x]=tot;
	zz2[tot]=y;
}
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs(int x){
	for (int i=fi[x];i;i=ne[i])
		if (!flag[zz[i]]){
			flag[zz[i]]=-flag[x];
			dfs(zz[i]);
		}
}
void dfs1(int x){
	for (int i=fi1[x];i;i=ne1[i])dfs1(zz1[i]);
	if (num1[x])Stack[++cnt]=x;
	while (cnt>=2){
		jb(Stack[cnt],Stack[cnt-1]);
		jb(Stack[cnt-1],Stack[cnt]);
		cnt-=2;
	}
}
void dfs2(int x){
	for (int i=fi2[x];i;i=ne2[i])dfs2(zz2[i]);
	if (num2[x])Stack[++cnt]=x;
	while (cnt>=2){
		jb(Stack[cnt],Stack[cnt-1]);
		jb(Stack[cnt-1],Stack[cnt]);
		cnt-=2;
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)num1[i]=num2[i]=1;
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		if (x!=-1)num1[x]^=1,jb1(x,i);
		else root1=i;
	}
	tot=0;
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		if (x!=-1)num2[x]^=1,jb2(x,i);
		else root2=i;
	}
	tot=0;
	for (int i=1;i<=n;i++)
		if (num1[i]!=num2[i]){
			puts("IMPOSSIBLE");
			return 0;
		}
	puts("POSSIBLE");
	dfs1(root1);
	cnt=0;
	dfs2(root2);
	for (int i=1;i<=n;i++)
		if (num1[i]&&!flag[i])flag[i]=1,dfs(i);
	for (int i=1;i<=n;i++)printf("%d ",flag[i]);
}


Measured memory_bytes: 10752
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
    // 整数の入力
    // int a;
    // cin >> a;
    // スペース区切りの整数の入力
    int b,c;
    cin >> b >> c;
    // 文字列の入力
    string s;
    cin >> s;
    // 出力
    s[c-1] = tolower(s[c-1]);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define PI 3.141592653589793
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
int main() {
  cout << fixed << setprecision(16);
  double a,b,x;
  cin>>a>>b>>x;
  double c=2*x/(a*b);
  double d=(2*x-a*a*b)/(a*a);
  double e=b-d;
  double z,m;
  if(x<a*a*b/2){
    z=atan(c/b);
    double degree = z * 180.0 / PI;
    putout(90.00000-degree);
  }
  if(x>=a*a*b/2){
    m=atan(a/e);
    double s=m*180.0/PI;
    putout(90.00000-s);
  }
  
  
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int N, x[3][100001], dp[3][100001];
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; i++) scanf("%d %d %d", &x[0][i], &x[1][i], &x[2][i]);
  for(int n = 1; n <= N; n++) {
    for(int m = 0; m < 3; m++) {
      for(int i = 0; i < 3; i++) {
        if(i == m) continue;
        dp[m][n] = max(dp[m][n], dp[i][n-1]+x[m][n]);
      }
    }
  }
  printf("%d", max(max(dp[0][N], dp[1][N]), dp[2][N]));
}

Measured memory_bytes: 2560
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,k;cin>>n>>k;string s;cin>>s;
	s[k-1]='a'+(s[k-1]-'A');
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void draw_rect(int h,int w)
{
	rep(i,h)rep(j,w)
	{
		cout<<'#';
		if(j == w-1)cout << endl;
	}
	return;
}

void solve()
{
	vector<int> hs,ws;
	while (true)
	{
		int h, w; cin >> h >> w;
		if(!h && !w)break;
		hs.push_back(h);
		ws.push_back(w);
	}
	rep(i,sz(hs))
	{
		draw_rect(hs[i],ws[i]);
		cout << "\n";
	}
	return;
}

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



Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;




int main(){
  int n;
 cin >> n;
 int i;
 if(n==1) cout << "Yes" << endl;
 else{

 for(i=2;i<=9;i++){
   if(n % i == 0 && n/i < 10){
     cout << "Yes" << endl;
     break;
   }
   else{
     if(i==9) cout << "No" << endl;
   }
 }
}



}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

int dp[10010];
int N, W, v[110], w[110];

int main()
{
    cin >> N >> W;
    rep(i, N) cin >> v[i] >> w[i];

    rep(i, N)
    {
        for(int j = W; 0 <= j; j--)
        {
            if(j + w[i] > W) continue;
            dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
        }
    }

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


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>

using namespace std;

string week;

void Main() {
  cin >> week;
  int ans = 0;

  if (week == "SUN") {
    ans = 7;
  } else if (week == "MON") {
    ans = 6;
  } else if (week == "TUE") {
    ans = 5;
  } else if (week == "WED") {
    ans = 4;
  } else if (week == "THU") {
    ans = 3;
  } else if (week == "FRI") {
    ans = 2;
  } else if (week == "SAT") {
    ans = 1;
  }

  cout << ans;
}

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

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

int main()
{
    ll N; cin >> N;
    vector<ll> ans(N, 0);
    map<ll,ll> m;
    ll maxv = sqrt(N);

    for (int i = 1; i < maxv; ++i) {
        for (int j = 1; j < maxv; ++j) {
            for (int k = 1; k < maxv; ++k) {

                ll tmp = i*i + j*j + k*k + i*j + j*k + k*i;
                //cout << tmp << endl;
                if (tmp <= N) {
                    m[tmp]++;
                }

            }
        }
    }
#if 1
    for (int i = 1; i <= N; ++i) {
        cout << m[i] << endl;
    }
#endif

}


Measured memory_bytes: 4208
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ms(x) memset(x,0,sizeof(x));
#define forn(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
#define sc(x) scanf("%d",&x)
#define bug(x) cerr<<#x<<":"<<(x)<<endl
using namespace std;
typedef long long ll;
const int M = 210000;
const int md=1e9+7;
vector<int> g[M];
int n;
int fac[M];
int inv[M];
void init(){
    fac[0] = 1;
    inv[0] = inv[1] = 1;
    forn(i,2,M-1) inv[i]=1ll*(md-md/i)*inv[md%i]%md;
    forn(i,1,M-1){
        fac[i] = 1ll*fac[i-1]*i%md;
        inv[i] = 1ll*inv[i-1]*inv[i]%md;
    }
}
int s[M]={0};
int A(int a,int b){
    return 1ll*fac[a]*inv[a-b]%md;
}
int dfs(int u,int f,int k,int d){
    if(k<=0) return 0;
    ll w=s[u];
    if(d==2) --k;
    if(w>k) return 0;
    ll an=A(k,w);
    for(auto t : g[u]){
        if(t==f) continue;
        an=an*dfs(t,u,k,d+1)%md;
    }
    return an;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    init();
    int a,b;
    int k;
    cin>>n>>k;
    if(n==1){
        cout<<k<<endl;
        return 0;
    }
    forn(i,2,n){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll an=k;
    s[1]=g[1].size();
    forn(i,2,n) s[i]=g[i].size()-1;
    cout<<an*dfs(1,1,k-1,1)%md<<endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    
    if(n % 10 == 9)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if(n/10 == 9)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <random>
#include <queue>
#include <map>
#include <ctime>
#include <sstream>
#include <cstdlib>
using namespace std;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std; int INF = 1e6; typedef long long ll; typedef double d; typedef unsigned long long ull;

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;
	--k;
	char ss = s[k];
	for (int i = 0; i < n; ++i) {
		if (s[i] != ss) {
			s[i] = '*';
		}
	}
	cout << s << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int i,cnt=0;
  string n;
  cin >> n;
  for(i=0; i<n.size(); i++){
    if(n.at(i)=='7'){
      cnt++;
    }
  }
  if(cnt>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    
    
    int prime[168]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
    //入力
    ll n;
    cin >> n;
    ll ans = 1;
    
    //処理
    int cnt[168]={};
    REP(i,0,168){
        REP(j,1,n+1){
            int tmp = j;
            while(tmp%prime[i]==0){
                cnt[i]++;
                tmp = tmp/prime[i];
            }
        }
    }
    REP(i,0,168){
        ans = ans*(cnt[i]+1)%MOD;
    }
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


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

int main()
{
	int N, M;
	long long H[100000];
	bool goodCheck[100000];
	

	std::cin >> N >> M;

	for (int i = 0; i < N; i++)
	{
		goodCheck[i] = true;
	}

	for (int i = 0; i < N; i++)
	{
		std::cin >> H[i];
	}
	for (int i = 0; i < M; i++)
	{
		int a, b;
		std::cin >> a >> b;
		a--;
		b--;
		if(H[a] <= H[b]){
			goodCheck[a] = false;
		}
		if(H[a] >= H[b]){
			goodCheck[b] = false;
		}
	}

	int count = 0;
	for (int i = 0; i < N; i++)
	{
		if (goodCheck[i])
		{
			count++;
		}
	}

	std::cout << count << endl;
	return 0;
}

Measured memory_bytes: 4500
n,c,k,*t=map(int,open(0).read().split())
t=sorted(t)
cnt=0
ans=1
x=t[0]
for i in range(n):
  cnt+=1
  if t[i]-x>k or cnt>c:
    x=t[i]
    ans+=1
    cnt=1
print(ans)

Measured memory_bytes: 14052
<?php
list($n, $t) = ints();
for ($i = 0; $i < $n; ++$i) list($a[], $b[]) = ints();
array_multisort($a, SORT_ASC, $b);
// dp[i][t] = s
// i番目までの料理のうち、t未満で食べ切れる満足度の最大値s
$dp[0] = array_fill(0, $t + 1, 0);
for ($i = 0; $i < $n; ++$i) {
    for ($_t = 0; $_t <= $t; ++$_t) {
        if ($_t > $a[$i]) {
            $dp[$i + 1][$_t] = max($dp[$i][$_t - $a[$i]] + $b[$i], $dp[$i][$_t]);
        } else {
            $dp[$i + 1][$_t] = $dp[$i][$_t];
        }
    }
}
$ans = 0;
for ($i = 0; $i < $n; ++$i) $ans = max($ans, $dp[$i][$t] + $b[$i]);
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 305644
#include <iostream>

using namespace std;
int main (){
    int a,b;
    cin >> a >> b;
    int c;
    if(a>b){
        c=a;
        a=b;
        b=c;
    }
    for (int i = 0; i < b; i++){
        cout << a;
    }
    cout << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A1(N), A2(N); 
    REP(i, N) cin >> A1[i];
    REP(i, N) cin >> A2[i];

    int ans = 0;
    int count = 0;
    REP(i, N)
    {
        count += A1[i];
        int count2 = 0;
        for(int j = i; j < N; j++)
        {
            count2 += A2[j];
        }
        ans = max(ans, count + count2);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
bool dp[51][851][851];
int N;
int main(){
	int s=0;
	cin>>N;
	dp[0][0][0]=1;
	rep(i,N){
		int t;
		cin>>t;
		s+=t;
		rep(j,851) rep(k,851) if(dp[i][j][k]){
			if(j+t<=850) dp[i+1][j+t][k]=1;
			if(k+t<=850) dp[i+1][j][k+t]=1;
			dp[i+1][j][k]=1;
		}
	}
	int ans=s;
	rep(j,851) rep(k,851) if(dp[N][j][k]) chmin(ans,max(max(j,k),s-j-k));
	cout<<ans<<endl;
}

Measured memory_bytes: 28180
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int k,x;
  cin>>k>>x;
  if(x>k*500)
  cout<<"No"<<endl;
  else if(x==(k*500))
    cout<<"Yes"<<endl;
  else if(x<k*500)
    cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            var word = Console.ReadLine().Split(' ');
            n = int.Parse(word[0]);
            m = int.Parse(word[1]);

            if (n == m)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  ll a,b,k;
  cin>>a>>b>>k;
  bool fg = true;
  while(k--){
    if( fg ){
      if( a&1 ) a--;
      b+=(a/2);
      a/=2;
    }
    else{
      if( b&1 ) b--;
      a+=(b/2);
      b/=2;
    }
    fg = !fg;
  }
  cout<<a<<' '<<b<<endl;
}


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

using namespace std;

template <std::uint_fast64_t Modulus> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  u64 x;

  constexpr ModInt(const u64 x = 0) noexcept : x(x % Modulus){};

  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    x += rhs.x;
    if (x >= Modulus) {
      x -= Modulus;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (x < rhs.x) {
      x += Modulus;
    }
    x -= rhs.x;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    x = x * rhs.x % Modulus;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 n = Modulus - 2;
    while (n) {
      if (n & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      n /= 2;
    }
    return *this;
  }
  constexpr ModInt operator++(int) noexcept {
    ModInt y = *this;
    x += 1;
    return y;
  }
  constexpr ModInt operator--(int) noexcept {
    ModInt y = *this;
    x -= 1;
    return y;
  }
  constexpr bool operator==(const ModInt rhs) noexcept {
    return x == rhs.x;
  }
  constexpr bool operator!=(const ModInt rhs) noexcept {
    return x != rhs.x;
  }

  friend std::istream &operator>>(std::istream &is, ModInt &rhs) {
    is >> rhs.x;
    return is;
  }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &rhs) {
    os << rhs.x;
    return os;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  using mint = ModInt<1000000007>;
  vector<vector<mint>> grid(H + 1, vector<mint>(W + 1, 0));
  grid[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i == 0 && j == 0) continue;
      if (S[i][j] == '#') continue;
      if (i > 0) grid[i][j] += grid[i - 1][j];
      if (j > 0) grid[i][j] += grid[i][j - 1];
    }
  }
  cout << grid[H - 1][W - 1] << '\n';
  return 0;
}


Measured memory_bytes: 9216
def split(line)
  idx = 1
  out = []
  while idx < line.size
    head = line[0,idx]
    tail = line[idx, line.size - idx]
    out.push([head, tail])
    idx += 1
  end
  return out
end


def compute(line)
  answers = {}
  splitted = split(line)
  splitted.each { |head, tail|
    #puts "#{head}|#{tail}"
    answers[ head + tail ] = 1
    answers[ head.reverse + tail ] = 1
    answers[ head + tail.reverse ] = 1
    answers[ head.reverse + tail.reverse ] = 1
    answers[ tail + head ] = 1
    answers[ tail.reverse + head ] = 1
    answers[ tail + head.reverse ] = 1
    answers[ tail.reverse + head.reverse ] = 1
  }
  #p answers
  puts answers.keys.size
end

num = gets.to_i
while line = gets
  compute(line.chomp)
end

Measured memory_bytes: 9936
#include<bits/stdc++.h>
using namespace std ;
#define ll long double 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	ll w , h , x , y ;
  	cin >> w >> h >> x >> y ;
  	cout << (w*h)/(ll)2 << " " ;
      if(x == w/2 && y == h/2){
        cout << 1 ;
        return 0 ;
      }
      else{
        cout << 0 ;
        return 0 ;
      }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(){
    vector<string> k{".,!? ", "abc", "def",
                     "ghi"  , "jkl", "mno",
                     "pqrs" , "tuv", "wxyz"};
    int n;
    cin >> n; cin.ignore();
    while(n--){
        string line;
        getline(cin, line);
        int button = -1, push = -1;
        for(char c: line){
            if(c == '0'){
                if(button == -1)continue;
                cout << k[button][push % (int)k[button].size()];
                button = push = -1;
            }
            else{
                button = c - '1';
                push++;
            }
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

    vector<long long> a(n);
    long long sum = 0;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        a[i] *= 2;
        sum += a[i];
    }
    sum /= 2;

    vector<long long> v(n);

    long long cnt = n/2;
    for(long long i = 0; i < cnt; i++){
        sum -= a[2*i];
    }
    v[n-1] = sum;
    v[0] = a[n-1] - v[n-1];

    for(long long i = n-2; i >= 0; i--){
        v[i] = a[i] - v[i+1];
    }

    for(long long i = 0; i < n; i++){
        if(i == n-1) printf("%lld\n", v[i]);
        else printf("%lld ", v[i]);
    }

    return 0;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	string s; cin >> s;
	string ans;
	if(s=="Sunny"){
		ans = "Cloudy";
	}else if(s=="Cloudy"){
		ans = "Rainy";
	}else{
		ans = "Sunny";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define sqr(x) (x)*(x)
using namespace std;

int main(){
#ifdef LOCAL
    freopen("inp.txt", "r", stdin );
    freopen("ans.txt", "w", stdout);
#endif
    ll k, x; cin >> k >> x;
    if(500*k>=x) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin());  // 先頭文字削除
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

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

    ll countT = 0;
    vector<string> A;
    vector<string> B;
    rep(i, Q) {
        ll T;
        cin >> T;
        if (T == 1) {
            countT++;
            continue;
        }
        ll F;
        string C;
        cin >> F;
        cin >> C;
        // debug(F);
        if (F == 1) {
            // debug("111");

            if (countT % 2 == 0) {
                A.pb(C);
            } else {
                B.pb(C);
            }
        } else {
            // debug("aaaaa");
            if (countT % 2 == 0) {
                B.pb(C);
            } else {
                A.pb(C);
            }
        }
    }
    // COUT("A");
    // for (string s : A) {
    //     cout << s;
    // }
    // ENDL;
    // COUT("B");
    // for (string s : B) {
    //     cout << s;
    // }
    // ENDL;
    // debug(countT);
    reverse(begin(A), end(A));
    if (countT % 2 == 0) {
        for (string s : A) {
            cout << s;
        }
        cout << S;
        // debug(S);
        for (string s : B) {
            cout << s;
        }
        // debug(S);
        ENDL;
    } else {
        reverse(begin(A), end(A));
        reverse(begin(B), end(B));
        for (string s : B) {
            cout << s;
        }
        reverse(S.begin(), S.end());
        cout << S;
        for (string s : A) {
            cout << s;
        }
        ENDL;
    }

    return 0;
}

Measured memory_bytes: 11760
import sys
import bisect
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list


X = ni()
l = get_primenumber(10 ** 5 +10)
idx = bisect.bisect_left(l, X)
print(l[idx])


Measured memory_bytes: 7512
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  int vwall[5][6] = {0}, hwall[5][6] = {0};
  string tmp;
  for (int i = 0; i < 9; i++) {
    cin >> tmp;
    if (i % 2 == 0)
      for (int j = 0; j < 4; j++)
        hwall[i/2][j+1] = tmp[j]-'0';
    else
      for (int j = 0; j < 5; j++)
        vwall[j][i/2+1] = tmp[j]-'0';
  }

  string str = "";
  enum Compass {N = 0, E, W, S};
  enum Compass compass = E;
  int x = 0, y = 0;
  while (true) {
    if (compass == E)
      if (vwall[x][y]) {
        compass = N;
        str += 'U';
        y--;
      } else if (hwall[y][x+1]) {
        x++;
        str += 'R';
      } else if (vwall[x][y+1]) {
        compass = S;
        str += 'D';
        y++;
      } else {
        compass = W;
      }
    else if (compass == W)
      if (vwall[x][y+1]) {
        compass = S;
        str += 'D';
        y++;
      } else if (hwall[y][x]) {
        x--;
        str += 'L';
      } else if (vwall[x][y]) {
        compass = N;
        str += 'U';
        y--;
      } else {
        compass = E;
      }
    else if (compass == N)
      if (hwall[y][x]) {
        compass = W;
        str += 'L';
        x--;
      } else if (vwall[x][y]) {
        y--;
        str += 'U';
      } else if (hwall[y][x+1]) {
        compass = E;
        str += 'R';
        x++;
      } else {
        compass = S;
      }
    else if (compass == S)
      if (hwall[y][x+1]) {
        compass = E;
        str += 'R';
        x++;
      } else if (vwall[x][y+1]) {
        y++;
        str += 'D';
      } else if (hwall[y][x]) {
        compass = W;
        str += 'L';
        x--;
      } else {
        compass = N;
      }
    if (x == 0 && y == 0) {
      cout << str << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double DET = 0.00000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



ll COM(int n, int k);
void COMinit();

int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, K;
	cin >> N >> K;

	COMinit();

	for (int i = 1; i <= K; i++) {

		if (N - K < i - 1) {
			cout << 0 << endl;
		}
		else {
			ll blue = COM((K - i) + (i - 1), i - 1);
			ll red = COM((N - K) - (i - 1) + i, i);

			cout << (blue * red) % MOD << endl;


		}
	}





}

// テーブルを作る前処理
ll fac[100000], finv[100000], inv[100000];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 100000; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


Measured memory_bytes: 2560
/*
* author: pavveu
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

template<class T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T value) {
	assert(matrix.empty());
	FOR (row, rows) 
		matrix.emplace_back(cols, value);
}

void go() {
	int n; cin >> n;
	vi a(n), b(n); 
	for(int& i : a) cin >> i;
	for(int& i : b) cin >> i;

	vi cnta(n + 1, 0); 
	vi cntb(n + 1, 0); 

	FOR(i, n) {
		cnta[ a[i] ]++;
		cntb[ b[i] ]++;
	}

	bool wrong = false;
	FOR(i, n + 1) {
		if ( cnta[i] + cntb[i] > n ) wrong = true;
	}

	if ( wrong ) { 
		cout << "No\n";
	} else {
		cout << "Yes\n";

		reverse(all(b));

		int x = -1;
		vi pos;
		for (int i = 0; i < n; i++) {
			if ( a[i] == b[i] ) {
				x = a[i];
			   	pos.emplace_back(i);
			}
		}

		vi other;
		for (int j = 0; j < n; j++ ) {
			if ( a[j] != x && b[j] != x ) {
				other.push_back(j);
			}
		}

		while ( pos.size() ) {
			swap( b[pos.back()], b[other.back()] );
			other.pop_back();
			pos.pop_back();
		}

		for (int x : b) {
			cout << x << " ";
		}
	}
}

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

	go();

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

template <class TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a)
{
  while (*sdbg != ',')
    cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
  os << "[";
  for (auto vv : V)
    os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

int n, k, a[110], dp[100010];
bool fn(int x)
{
  if(x < a[0]) return 0;
  int &res = dp[x];
  if(res != -1) return res;
  res = 0;
  for(int i = 0; i < n && a[i] <= x; i++)
  if(!fn(x - a[i])) {
    res = 1;
    break;
  }
  return res;
}
main()
{
  memset(dp, -1, sizeof(dp));
  cin >> n >> k;
  for(int i = 0; i < n; i++)
  cin >> a[i];
  if(fn(k)) 
  cout << "First";
  else 
  cout << "Second";
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void)
{
	char pattern[16][16] = {0};
	int i, j;
	
	for (i = 0; i < 8; i++) scanf("%s", pattern[i]);
	puts("90");
	for (i = 0; i < 8; i++){
		for (j = 7; j >= 0; j--){
			putchar(pattern[j][i]);
		}
		puts("");
	}
	puts("180");
	for (i = 7; i >= 0; i--){
		for (j = 7; j >= 0; j--){
			putchar(pattern[i][j]);
		}
		puts("");
	}
	puts("270");
	for (i = 7; i >= 0; i--){
		for (j = 0; j < 8; j++){
			putchar(pattern[j][i]);
		}
		puts("");
	}
	
	return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, s=1, c=0, l;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    k=a[0];
    for(i=1; i<n; i++)
    {
        if(a[i]<=k)
        {
            k=a[i];
            s++;
        }
    }
    cout << s << endl;
}


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


int main(void){
	string a;
	cin >> a;
	int b =0 ,c =0;
	for(int e=0;e<a.size();e++){
		if(a[e]=='A') b++;
		else c++;
	}
	if(b==3||c==3) printf("No");
	else printf("Yes");
	return 0;
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
a, b, x = [int(x) for x in input().strip().split()]
if x >= a ** 2 * b / 2:
    theta = math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3)))
else:
    theta = math.degrees(math.atan(a * (b ** 2) / (2 * x)))
print(theta)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    int n, x, min = 1000000, max = -1000000;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        sum += x;
        if (x < min) min = x;
        if (x > max) max = x;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

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

using namespace std;

long double pi = 6.28318530717958623200;

int main() {
	int n;
	cin >> n ;
	std::vector<int> arr(n,0) ;
	vector<int> boss(n,0);
	for(int i=1;i<n;++i){
	    cin >> arr[i];
	    boss[arr[i]-1]++;
	}
	for (int i=0;i<n;++i){
	    cout << boss[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int solve(){
    int N;
    cin >> N;
    vector <vector <int> > g(N);
    vector <int> c(N);
    vector <int> res(N);
    vector <int> used(N,0);

    REP(i, N-1)
    {
        int a,b;
        cin >> a >> b;
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    REP(i, N)cin >> c[i];

    sort(c.rbegin(),c.rend());
    int isum = 0;

    for(int i = 1; i < N; ++i)
    {
        isum += c[i];
    }

    
    queue <ll> q;
    //0の根付き木としてcを降順に割り振る
    q.push(0);
    used[0] = 1;
    int cnt = 0;
    res[0] = c[cnt++];
    while(!q.empty())
    {
        int cur = q.front();
        q.pop();

        for(int i = 0; i < g[cur].size(); ++i)
        {
            int tar = g[cur][i];
            if(used[tar])continue;
            used[tar] = 1;
            res[tar] = c[cnt++];
            q.push(tar);
        }
    }


    cout << isum << endl;

    for(auto v:res)
    {
        cout << v << " ";
    }
    cout << endl;

    return 0;

}

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


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string S;

int main(){
    cin>>S;

    string T;
    rep(i,S.size()){
        if(i!=S.size()-1 && S[i]=='B' && S[i+1]=='C'){
            T+='X';
            i++;
        }else{
            T+=S[i];
        }
    }
    
    ll ans=0;
    ll cnt=0;
    for(int i=T.size()-1;i>=0;i--){
        if(T[i]=='X'){
            cnt++;
        }else if(T[i]=='A'){
            ans+=cnt;
        }else{
            cnt=0;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 776
def check(i,j):
  if s[j-1]=='o':
    if a[j-1]=='S':return a[i]==a[j]
    else:return a[i]!=a[j]
  else:
    if a[j-1]=='S':return a[i]!=a[j]
    else:return a[i]==a[j]
n=int(input())
s=input()
sw='SW'
for i in 'SS','SW','WS','WW':
  a=i
  for i,j in enumerate(s[1:n-1],1):
    if j=='o':
      if a[-1]=='S':a+=a[-2]
      else:a+=sw[a[-2]=='S']
    else:
      if a[-1]=='S':a+=sw[a[-2]=='S']
      else:a+=a[-2]
  if check(-1,1) and check(-2,0):
    flag=1
    break
  else:flag=0
print([-1,a][flag])

Measured memory_bytes: 213904
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
a = inpl()

if np.sum(a) > n:
    ans = -1
else:
    ans = n - np.sum(a)
print(ans)

Measured memory_bytes: 31700