akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double n, m; cin >> n >> m;
    vector<double> a(n);
    double sum = 0;
    rep(i,n) cin >> a[i], sum += a[i];
    int cnt = 0;
    rep(i,n) {
        if (a[i] >= sum/(4*m)) cnt++;
    }
    if (cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int maxLength = str.length();
        String[] ar = str.split("");

        boolean flag = false;
        for(int i=0; i < maxLength; i++) {
            if(ar[0].equals(ar[i]) != true) {
                flag = true;
                break;
            }
        }

        if (flag) {
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1980;

i64 xor128()
{
  static i64 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  i64 t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

i64 D;
i64 c[26];
i64 s[365][26];
vector<i64> ans;

i64 eval(vector<i64> &ans)
{
  i64 score = 0;
  i64 last[26] = {};
  for (i64 i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (i64 j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  chrono::system_clock::time_point end = start + chrono::milliseconds(timeLimit);
  i64 bestScore = -1e18, loop = 0;
  while (chrono::system_clock::now() < end)
  {
    i64 t[3] = {xor128() % D, xor128() % 26};
    t[2] = ans[t[0]];
    ans[t[0]] = t[1];
    i64 score = eval(ans);
    if (bestScore < score)
    {
      bestScore = score;
    }
    else
    {
      ans[t[0]] = t[2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (i64)(1e6) << endl
       << "loop: " << loop << endl;
}

void input()
{
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (i64 i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

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


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int n, k, a[maxn];
vector<int> b, c;
const ll mod = 1e9 + 7;
bool check(int b, int c, int k)
{
	if(k & 1)
		return b > 0 && 2 * ((b - 1) / 2 + c / 2) + 1 >= k;
	else
		return 2 * (b / 2 + c / 2) >= k;
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &a[i]);
		if(a[i] > 0) b.push_back(a[i]);
		else if (a[i] < 0) c.push_back(a[i]);
	}
	if(check(b.size(), c.size(), k))
	{
		sort(b.begin(), b.end(), greater<int>());
		sort(c.begin(), c.end());
		ll ans = 1; 
		int i = 0, j = 0;
		if((k & 1) && b.size() > 0)
		{
			ans = ans * b[i] % mod;
			++i, --k;
		}
		while(k)
		{
			if(i + 1 < b.size() && j + 1 < c.size())
			{
				if(1ll * b[i] * b[i + 1] > 1ll * c[j] * c[j + 1])
					ans = ans * b[i] % mod * b[i + 1] % mod, i += 2;
				else
					ans = ans * (mod + c[j]) % mod * (mod + c[j + 1]) % mod, j += 2;
			}
			else if(i + 1 < b.size())
				ans = ans * b[i] % mod * b[i + 1] % mod, i += 2;
			else if (j + 1 < c.size())
				ans = ans * (mod + c[j]) % mod * (mod + c[j + 1]) % mod, j += 2;
			k -= 2;
		}
		printf("%lld\n", ans);
	}
	else if (b.size() + c.size() < n) printf("0\n");
	else
	{
		sort(b.begin(), b.end());
		sort(c.begin(), c.end(), greater<int>());
		ll ans = 1; 
		int i = 0, j = 0;
		if((k & 1) && c.size() > 0)
		{
			ans = ans * (mod + c[j]) % mod;
			++j, --k;
		}
		while(k)
		{
			if(i + 1 < b.size() && j + 1 < c.size())
			{
				if(1ll * b[i] * b[i + 1] <= 1ll * c[j] * c[j + 1])
					ans = ans * b[i] % mod * b[i + 1] % mod, i += 2;
				else
					ans = ans * (mod + c[j]) % mod * (mod + c[j + 1]) % mod, j += 2;
			}
			else if(i + 1 < b.size())
				ans = ans * b[i] % mod * b[i + 1] % mod, i += 2;
			else if (j + 1 < c.size())
				ans = ans * (mod + c[j]) % mod * (mod + c[j + 1]) % mod, j += 2;
			else
				ans = ans * (mod + c[j]) % mod * b[i] % mod;
			k -= 2;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

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

  string s;
  cin >> s;

  set<char> a;
  for (char c : s) {
    a.insert(c);
  }

  string ans = "None";
  for (char i = 'a'; i <= 'z'; i++) {
    if (a.find(i) == a.end()) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;
 
const int N=1050005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}
int w,h,n,cnt,ans,x[N],y[N],yy[N],sta[N][2],g[N][2],top[2];
int p[N<<1],flag[N<<1];
 
inline void ins(int x){if(x>=1&&x<h) yy[++cnt]=x;}
inline int get(int y){return lower_bound(yy+1,yy+cnt+1,y)-yy;}
inline void add(int k,int b){p[k]+=b;flag[k]+=b;}
inline void push(int k){
	if(!flag[k]) return;
	add(ls,flag[k]);add(rs,flag[k]);
	flag[k]=0;
}
void ch(int l,int r,int x,int y,int k,int b){
	if(x<=l&&r<=y){add(k,b);return;}
	push(k);
	int mid=l+r>>1;
	if(x<=mid) ch(l,mid,x,y,ls,b);
	if(y>mid) ch(mid+1,r,x,y,rs,b);
	p[k]=max(p[ls],p[rs]);
}
void build(int l,int r,int k){
	if(l==r){p[k]=-yy[l];return;}
	int mid=l+r>>1;
	build(l,mid,ls);build(mid+1,r,rs);
	p[k]=max(p[ls],p[rs]);
}
void solve(int mid){
	clr(flag,0);clr(top,0);cnt=0;
	ins(1);ins(h-1);
	for(int i=1;i<=n;i++){
		ins(y[i]);
		ins(y[i]-1);
		ins(y[i]+1);
	}
	sort(yy+1,yy+cnt+1);
	cnt=unique(yy+1,yy+cnt+1)-yy-1;
	if(!cnt){printf("%d\n",(w+h)*2);exit(0);}
	build(1,cnt,1);
	for(int i=1;i<=cnt;i++)
		g[i][0]=mid,g[i][1]=w-mid;
	for(int i=1;i<=n;i++){
		if(!y[i]||y[i]==h) continue;
		if(x[i]<=mid) gmin(g[get(y[i])][0],mid-x[i]); else gmin(g[get(y[i])][1],x[i]-mid);
	}
	for(int i=1;i<=cnt;i++){
		for(int x=0;x<2;x++){
			int last=i;
			ch(1,cnt,i,i,1,g[i][x]);
			while(top[x]&&g[sta[top[x]][x]][x]>g[i][x]){
				int l=sta[top[x]-1][x]+1,r=sta[top[x]][x];
				ch(1,cnt,l,r,1,g[i][x]-g[r][x]);
				top[x]--;
			}
			sta[++top[x]][x]=i;
		}
		gmax(ans,(p[1]+yy[i]+2)*2);
	}
}
 
int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	solve(w/2);
	for(int i=1;i<=n;i++)
		swap(x[i],y[i]);
	swap(w,h);solve(w/2);
	printf("%d\n",max(ans,max(w,h)*2+2));
	return 0;
}


Measured memory_bytes: 37120
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < (ll)(r); i++)
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    ll ans = 0;
    FOR(i,0,10){
        int indi = 0;
        while(indi <= N-1 && S[indi] != ('0'+i)) indi++;
        if(indi > N-3) continue;
        FOR(j,0,10){
            int indj = indi+1;
            while(indj <= N-1 && S[indj] != ('0'+j)) indj++;
            if(indj > N-2) continue;
            FOR(k,0,10){
                int indk = indj+1;
                while(indk <= N-1 && S[indk] != ('0'+k)) indk++;
                if(indk > N-1) continue;
                else ans++;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
#include<string>
#include<sstream>
using namespace std;
int main() {
string s;
while(cin>>s){
	if(s[0]==s[1]&&s[1]==s[2]&&s[0]!='s'){cout<<s[0]<<endl;continue;}
	else if(s[3]==s[4]&&s[4]==s[5]&&s[3]!='s'){cout<<s[3]<<endl;continue;}
	else if(s[6]==s[7]&&s[7]==s[8]&&s[6]!='s'){cout<<s[6]<<endl;continue;}
	else if(s[0]==s[3]&&s[3]==s[6]&&s[0]!='s'){cout<<s[0]<<endl;continue;}
	else if(s[1]==s[4]&&s[4]==s[7]&&s[1]!='s'){cout<<s[7]<<endl;continue;}
	else if(s[2]==s[5]&&s[5]==s[8]&&s[2]!='s'){cout<<s[2]<<endl;continue;}
	else if(s[0]==s[4]&&s[4]==s[8]&&s[0]!='s'){cout<<s[0]<<endl;continue;}
	else if(s[2]==s[4]&&s[4]==s[6]&&s[2]!='s'){cout<<s[2]<<endl;continue;}
	else{cout<<"d"<<endl;}
}
}

Measured memory_bytes: 3152
#include<iostream>
int main()
{
    int a,b,c,d;
    std::cin >> a >> b >> c >> d; 
    while (0<1){
        c-=b;
        if (c<=0){
            std::cout << "Yes" << std::endl;
            return 0;
        }
        
        a-=d;
        if (a<=0){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll dp[110][200010];
ll sum[200010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    vector<int> a(N);
    for(int i=0;i<N;++i) cin >> a[i];
    dp[0][K] = 1;
    for(int i=1; i<=N; ++i){
        // cum sum
        for(int j=0; j<=K+a[i-1];++j) sum[j+1] = sum[j] + dp[i-1][j];
        // dp
        for(int j=0; j<=K; ++j) (dp[i][j] += sum[j+a[i-1]+1] - sum[j]) %= MOD;
    }
    cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 159488
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,0,n) cin>>a[i];
  sort(all(a));
  ll c=0;
  rep(i,0,n) c+=a[i];
  co(a[0]<<" "<<a[n-1]<<" "<<c);
  return 0;
}


Measured memory_bytes: 3176
// ABC065B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;
int main()
{
	int N;
	cin >> N;

	int j = 1;
	int count = 0;
	bool check = false;
	vector<int> a(N+1);
	for (int i = 1; i <= N; i++)
	{
		cin >> a.at(i);
	}
	for (int k = 1; k <= N; k++)
	{
		if (a.at(j)==2)
		{
			count++;
			check = true;
			break;
		}
		else
		{
			j = a.at(j);
			count++;
		}
	}
	if (check==true)
	{
		cout << count << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<algorithm>
#include<set>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
typedef long long LL;

const int maxn = 2e3 + 5;
LL a[maxn];
LL b[maxn][maxn];
int main(){
    int n;
    LL x,sum = 1LL << 60LL;
    cin >> n >> x;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= n;i++){
        b[i][0] = a[i];
        for(int k = 1;k <= n - 1;k++){
            int pos = i - k;
            if(pos <= 0) pos = n - abs(pos);
            b[i][k] = min(b[i][k - 1],a[pos]);
        }
    }
    for(int k = 0;k <= n - 1;k++){
        LL ans = 0;
        for(int i = 1;i <= n;i++){
            ans += b[i][k];
        }
        sum = min(sum,ans + x * k);
    }
    cout << sum << endl;
}

Measured memory_bytes: 31616
#include <string>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int a, b, c, d;
int main() {
	cin >> a >> b >> c;
	for (int i = 1; i <= 1000; i++) {
		if (a % i == 0 && b % i == 0) d = i;
	}
	cout << (c % d == 0 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1000
#define INF 1e9
 
int V;
struct State {
    int x, y;
};
 
vector<State> vec;
 
double check(State a, State b)
{
    return sqrt(pow((a.x-b.x),2.) + pow(a.y-b.y,2.));
}
 
double dist[MAX];
bool used[MAX];
int _prev[MAX];
double cost[MAX][MAX];
 
void dijkstra(int s, int t)
{
    fill(dist, dist+MAX, INF);
    memset(used, false, sizeof(used));
    memset(_prev, -1, sizeof(_prev));
    dist[s] = 0;
 
    while (true) {
	int v = -1;
	for (int u = 0; u < V; u++) {
	    if (!used[u] && (v == -1 || 
			    dist[u] < dist[v])) {
		v = u;
	    }
	}
	if (v == -1) {
	    break;
	} else {
	    used[v] = true;
	}
 
	for (int u = 0; u < V; u++) {
	    if (dist[u] > dist[v] + cost[u][v] && cost[u][v] <= 50) {
		dist[u] = dist[v] + cost[u][v];
		_prev[u] = v;
	    }
	}
    }
 
    if (dist[t] == INF) {
	cout << "NA" << endl;
    } else {
	vector<int> path;
	for (int i = t; i != -1; i = _prev[i]) { 
	    path.push_back(i);
	}
	reverse(path.begin(), path.end());
     
	int len = path.size();
	for (int i = 0; i < len; i++) {
	    cout << path[i]+1 << (i == len-1 ? '\n' : ' ');
	}
    }
}
 
int main()
{
    int n, start, goal, num;
    State s;
 
    while (cin >> V, V) {
	State distance[MAX];
 
	vec.clear();
	fill(cost[0], cost[V], INF);
	for (int i = 0; i < V; i++) {
	    cin >> num >> s.x >> s.y;
	    vec.push_back(s);
	    distance[num-1] = s;
	}
 
	for (int i = 0; i < V-1; i++) {
	    for (int j = i+1; j < V; j++) {
		cost[i][j] = cost[j][i] = 
		    check(distance[i], distance[j]);
	    }
	}
  
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> start >> goal;
	    start--, goal--;
	    dijkstra(start, goal);
	}
    }
    return 0;
}

Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		while((n = sc.nextInt()) != 0){
			System.out.println(getCount(n));
		}
	}
	
	private static int getCount(int n){
		int count = 0;
		int num = n;
		while(num != 1){
			if(num % 2 == 0)	num /= 2;
			else		num = num * 3 + 1;
			count++;
		}
		return count;
	}
}

Measured memory_bytes: 17188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    int a = 0, b = 0;
    bool color[20]; fill(color, color + 20, false);
    rep(i, n){
      int rate; cin >> rate;
      if(rate < 3200){
        if(!color[rate/400]){
        color[rate/400] = true;
        a++;
        }
      }
      else b++;
    }
    int Min = max(1, a);
    int Max = min(n, a + b);
    cout << Min << " " << Max << ln;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<int>> ans(h, vector<int>(w));

  int k = 0;
  rep(x, n) {
    rep(y, a[x]) {
      int i = k/w;
      int j = k%w;
      if(i%2==1) j = w-1-j;

      ans[i][j] = x+1;
      ++k;
    }
  }
  rep(i, h) line_out(ans[i]);
}


Measured memory_bytes: 3656
def dijkstra(start_node, num_nodes, cost_dict):
    import heapq

    initial_nodes = cost_dict[start_node]
    min_costs = {start_node : 0}
    available_nodes = initial_nodes
    done_nodes = set([start_node])
    heapq.heapify(available_nodes)
    
    # Loop until all nodes are searhced
    while len(available_nodes) > 0:
        (min_cost, dest_node) = heapq.heappop(available_nodes)
        if(dest_node in done_nodes):
            continue
        min_costs[dest_node] = min_cost
        done_nodes.add(dest_node)
        # New available nodes
        for new_node in cost_dict[dest_node]:
            new_node_cost = new_node[0] + min_cost
            new_node_dest = new_node[1]
            if(new_node_dest in done_nodes):
                continue
            heapq.heappush(available_nodes, (new_node_cost, new_node_dest))
    return min_costs

def main():
    import copy
    H, W = map(int, input().split())
    cost_dict_org={i:[] for i in range(10)}
    for i in range(10):
        c_list = list(map(int, input().split()))
        for j in range(10):
            cost_dict_org[i].append((c_list[j], j))
    
    min_cost_dict = {}
    

    for i in range(10):
        cost_dict = copy.deepcopy(cost_dict_org)
        min_dict = dijkstra(i, 10, cost_dict)
        min_cost_dict[i]=min_dict
    
    A = []

    answer = 0
    for h in range(H):
        a_row = list(map(int, input().split()))
        for a in a_row:
            if(a == 1 or a == -1):
                continue
            else:
                answer += min_cost_dict[a][1]
    print(answer)


main()

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

int main() {
  int N;
  cin >> N;
  int a = N/1000;
  int b = (N % 1000)/100;
  int c = (N % 100)/10;
  int d = N % 10;
  
    if (a == b && b == c) {
    cout << "Yes"  << endl;
  }

  else if (b == c && c == d) {
    cout << "Yes"  << endl;
  }

  else  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
def main():
    n = int(input())
    A = list(map(int, input().split()))
    i = 1
    ans = 0
    for a in A:
        if a == i:
            i += 1
        else:
            ans += 1
    # ans==nのときは Aに1がないので -1を出力.
    print(ans if ans!=n else -1)
main()

Measured memory_bytes: 26140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin >> s;
    bool check[4];
    int n = s.size();
    for(int i = 0; i < 4; i++){
        check[i] = false;
    }
    for(int i = 0; i < n; i++){
        if(s[i] == 'N'){
            check[0] = true;
        }
        if(s[i] == 'S'){
            check[1] = true;
        }
        if(s[i] == 'E'){
            check[2] = true;
        }
        if(s[i] == 'W'){
            check[3] = true;
        }
    }
    /*if(check[0] == true){
        if(check[1] == true){
            cout << "No" << endl;
            return 0;
        }
    }
    if(check[2] == true){
        if(check[3] == true){
            cout << "No" << endl;
            return 0;
        }
    }*/
    if((check[0] ^ check[1]) || (check[2] ^ check[3])){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
using vint = vector<int>;
using vvint = vector<vint>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
constexpr double pi = 3.1415926535897932384626433832795028L;

int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int sigma_2(int n) {
  if (n == 0) {
    return 0;
  }
  return n + sigma_2(n - 1);
}
int sum_range(int a, int b) {
  if (a == b) {
    return a;
  }
  return sum_range(a, b - 1) + b;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}

int array_sum_from_i(vint &data, int i) {
  if (i == data.size()) {
    return 0;
  }
  int s = array_sum_from_i(data, i + 1);
  return data[i] + s;
}
int array_sum(vint &data) {
  return array_sum_from_i(data, 0);
}
bool has_divisor(int N, int i) {
  if (i == N) {
    return false;
  }
  if (N % i == 0) {
    return true;
  }
  return has_divisor(N, i + 1);
}

bool is_prime(int N) {
  if (N == 1) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else {
    return !has_divisor(N, 2);
  }
}
bool is_even(int);
bool is_odd(int);

bool is_even(int n) {
  if (n == 0) {
    return true;
  }
  return is_odd(n - 1);
}

bool is_odd(int n) {
  if (n == 0) {
    return false;
  }
  return is_even(n - 1);
}








signed main() {
    int x,y,z;
    cin >> x >> y >> z;

    cout << z << ' '<< x << ' '<< y<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, A[111], S = 0, C = 0;

  std::cin >> N >> M;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    S += A[i];
  }

  for (int i = 0; i < N; i ++)
    if (A[i] >= S / 4.0 / M)
      C ++;

  std::cout << (C >= M ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import Counter
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, S: str):
    c = Counter(S)
    count = c["R"] * c["G"]*c["B"]
    for i in range(1, (N-3)//2+2):
        for j in range(N):
            if j+2*i >= N:
                break
            if not (S[j] == S[j+i] or S[j] == S[j+i+i] or S[j+i] == S[j+i+i]):
                count -= 1
    print(count)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74116
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;
int dif[MAX];
int acs(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}
int des(const void *a, const void *b)
{
  return dif[*(int *)b] - dif[*(int *)a];
}

int main(void)
{
  int n, m;
  scanf("%d %d", &n, &m);
  int x[MAX];
  rep(i, 0, m) scanf("%d", &x[i]);
  if (n >= m)
  {
    printf("0\n");
    return 0;
  }
  int idx[MAX];
  rep(i, 0, m) idx[i] = i;
  qsort(x, m, sizeof(int), acs);
  rep(i, 0, m - 1) dif[i] = x[i + 1] - x[i];
  rep(i, 0, m - 1) idx[i] = i;
  qsort(idx, m - 1, sizeof(int), des);
  int ans = x[m - 1] - x[0];
  rep(i, 0, n - 1)
  {
    ans -= dif[idx[i]];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1652
n, m = gets.split.map(&:to_i)
if (n - m).abs > 1
  puts '0'
  exit
end
MOD = 1_000_000_007
ans = 1
1.upto([n, m].min) do |i|
  ans *= i
  ans %= MOD
  ans *= i
  ans %= MOD
end
if n == m
  ans *= 2
else
  ans *= [n, m].max
end
ans %= MOD
puts ans

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

int main (){

    long long int N,i,j=1;
    cin >> N;
    long long int A[N+5],ans=N;
    for(i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A,A+N);

    for(i = 0; i < N-1; i++) {
        if(A[i] * 2 >= A[i+1]) {
            A[i+1] += A[i];
            j++;
        }else {
            A[i+1] += A[i];
            ans -= j;
            j = 1;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#define INF INT_MAX

int cnt,n;

void merge(int *,int,int,int);
void MergeSort(int *,int,int);

int main(){
  int i;
  int *A;
  cnt=0;
  
  scanf("%d",&n);
  A = (int *)malloc(n*sizeof(int));
  for(i=0; i<n; i++)scanf("%d",&A[i]);
  
  MergeSort(A,0,n);
  
  for(i=0; i<n; i++){
    if(i != 0) printf(" ");
    printf("%d",A[i]);
    }
  printf("\n");
  
  printf("%d\n",cnt);

  free(A);
  
  return 0;
}


void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;
  
  int *l,*r;
  l = (int *)malloc((n1+2)*sizeof(int));
  r = (int *)malloc((n2+2)*sizeof(int));
  
  for(i=0; i<n1; i++) l[i] = A[left+i];
  for(i=0; i<n2; i++) r[i] = A[mid+i];
  l[n1]=r[n2]=INF;
  
  i=j=0;
  for(k=left; k<right; k++){
    cnt++;
    if(l[i] <= r[j]){
      A[k] = l[i];
      i++;
    }else{
      A[k] = r[j];
      j++;
    }
  }
  
  free(l);
  free(r);
}

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



Measured memory_bytes: 5432
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>

using namespace std;

int a[100005];

int main(){
	int n, i;
	cin>>n;
	for(i = 0; i<n; i++)
		cin>>a[i];
	sort(a, a+n);
	int c = 1, e = 0, dis = 1;
	for(i = 0; i<n-1; i++){
		if(a[i] != a[i+1]){
			dis++;
			if(c%2 == 0)
				e++;
			c = 1;
		}
		else{
			c++;
		}
	}
	if(c%2 == 0)
		e++;
	if(e%2 == 0)
		cout<<dis<<endl;
	else cout<<dis-1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define int long long
using namespace std;
const int INF = 1e9 + 7;

int N;

signed main()
{
    cin >> N;
    if (N % 2) {
        cout << N * (N - 1) / 2 - (N - 1) / 2 << endl;
        for (int i = 1; i < N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (i + j != N) {
                    cout << i << " " << j << endl;
                }
            }
        }
    } else {
        cout << N * (N - 1) / 2 - N / 2 << endl;
        for (int i = 1; i < N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (i + j != N + 1) {
                    cout << i << " " << j << endl;
                }
            }
        }
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    if(N == 1) {
        cout << 1;
    }
    else if(N == 2 || N == 3) {
        cout << 2;
    }
    else if(64 <= N) {
        cout << 64;
    }
    for(int i = 2; i <= 5; i++) {
        if( (int)pow(2.0, i) <= N && N < (int)pow(2.0, i+1) ) {
            cout << (int)pow(2.0, i);
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int a,b[100100];
  cin >> a;
  b[0]=0;
  rep(i,100100)b[i]=0;
  rep(i,100100){if(i+1<100100&&(b[i+1]==0||b[i+1]>b[i]+1))b[i+1]=b[i]+1;
                if(i+6<100100&&(b[i+6]==0||b[i+6]>b[i]+1))b[i+6]=b[i]+1;
                if(i+36<100100&&(b[i+36]==0||b[i+36]>b[i]+1))b[i+36]=b[i]+1;
                if(i+216<100100&&(b[i+216]==0||b[i+216]>b[i]+1))b[i+216]=b[i]+1;
                if(i+1296<100100&&(b[i+1296]==0||b[i+1296]>b[i]+1))b[i+1296]=b[i]+1;
                if(i+7776<100100&&(b[i+7776]==0||b[i+7776]>b[i]+1))b[i+7776]=b[i]+1;
                if(i+46656<100100&&(b[i+46656]==0||b[i+46656]>b[i]+1))b[i+46656]=b[i]+1;
                if(i+9<100100&&(b[i+9]==0||b[i+9]>b[i]+1))b[i+9]=b[i]+1;
                if(i+81<100100&&(b[i+81]==0||b[i+81]>b[i]+1))b[i+81]=b[i]+1;
                if(i+729<100100&&(b[i+729]==0||b[i+729]>b[i]+1))b[i+729]=b[i]+1;
                if(i+6561<100100&&(b[i+6561]==0||b[i+6561]>b[i]+1))b[i+6561]=b[i]+1;
                if(i+59049<100100&&(b[i+59049]==0||b[i+59049]>b[i]+1))b[i+59049]=b[i]+1;
               }
  printf("%d",b[a]);
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	llint n, k;
	cin >> n >> k;
	llint ans = k;
	for (int i = 1;i < n;i++) {
		ans *= k - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def func(n, lf):
    cnt = 0
    if lf > 0:
        dif = alp[lf] - alp[lf-1]
    else:
        dif = 1
    while n > dif:
        n -= dif
        cnt += 1
    return n, cnt

N = int(input())

sam = [chr(i) for i in range(97, 97+26)]

alp = []
alp.append(0)
num = 26
i = 1
while num <= 1000000000000001:
    alp.append(num)
    i += 1
    num += 26 ** i

#print(alp)

ans = ''
l = len(alp) - 1

while 1:
    if N - alp[l] > 0:
        break
    l -= 1

#print(l)

N = N - alp[l]

while l >= 0:
    ret = func(N, l)
    ans = ans + sam[ret[1]]
    N = ret[0]
    l -= 1

print(ans)

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

using namespace std;

int main(){
	long long  n;
	cin>>n;
	long long  sum = 0;
	for(long long  i=1;i<=n;i++){
		if(i%3==0&&i%5==0){
			continue;
		}
		if(i%3==0){
			continue;
		}
		if(i%5==0){
			continue;
		}
		sum += i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))

K = sum(A) / sum(range(1, N+1))
D = [A[i+1] - A[i] - K for i in range(-1, N-1)]
for d in D:
    if not (d <= 0 and d % N == 0):
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,q,i,t,x;
   cin>>n>>q;
   vector<vector<int> >a(n);
   while(q){
   	q--;
   	cin>>i;
   	if(i==0){
   		cin>>t>>x;
   		a[t].push_back(x);
	   }
	if(i==1){
		cin>>t;
		int j;
        for(j=0;j<a[t].size();j++){
        	if(j==0)
            cout<<a[t][j];
            else
            cout<<" "<<a[t][j];
        }
        cout<<endl;
   }
   if(i==2){
   	cin>>t;
   	a[t].clear();
   }
}
}



Measured memory_bytes: 5864
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>

using namespace std;
using ll = long long;

int sumRank(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int count = 0;
    for (auto i = 1; i <= n; i++) {
        auto sumR = sumRank(i);
        if (a <= sumR && sumR <= b) {
            count += i;
            cerr << i << " " << sumR << endl;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<complex>
using namespace std;
int main(){
  int i,n,k;
  cin >> n;
  cin >> k;

  double dist,xi;
  dist = 0;
  for (i=0; i<n; i++){
    cin >> xi;
    double dist_b = abs(xi - k);
    if(xi <= dist_b) dist += 2 * xi;
    else dist += 2 * dist_b;
  }

  cout << dist << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
bool dp1[10];
bool dp2[100];
bool dp3[1000];
char S[30001];

int main() {
    int n;
    scanf("%d", &n);
    scanf(" %s", S);

    for(int i = 0; i < 10; i++) dp1[i] = false;
    for(int i = 0; i < 100; i++) dp2[i] = false;
    for(int i = 0; i < 1000; i++) dp3[i] = false;

    for(int i = 0; i < n; i++) {
        int d = S[i] - '0';
        for(int j = 0; j < 100; j++) dp3[j * 10 + d] |= dp2[j];
        for(int j = 0; j < 10; j++) dp2[j * 10 + d] |= dp1[j];
        dp1[d] = true;
    }

    int ans = 0;
    for(int i = 0; i < 1000; i++) ans += dp3[i] ? 1 : 0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	vector<string>A(S.size() - 2);
	vector<int>B(S.size() - 2);
	vector<int>C(S.size() - 2);

	for (int i = 0; i < S.size() - 2; i++) {
		A[i] = S.substr(i, 3);
	}
	for (int i = 0; i < S.size() - 2; i++) {
		B[i] = stoi(A[i]);
	}
	for (int i = 0; i < S.size() - 2; i++) {
		C[i] = abs(753 - B[i]);
	}
	sort(C.begin(), C.end());
	cout << C[0] << endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, b, h;
  std::cin >> a >> b >> h;
  std::cout << (a + b) * h / 2 << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

map<int,int> team;
priority_queue<int> score;
priority_queue<int> score2;

int main(void){
	int a,b;
	while(1){
		scanf("%d,%d",&a,&b);
		if(a==0 && b==0)break;
		team.insert(map<int,int>::value_type(a,b));
		score.push(b);
	}
	while(~scanf("%d",&a)){
		int t;
		int rank=1;
		t=team[a];
		score2=score;
		bool ch=true;
		while(ch){
			int Us=0;
			if(t==score2.top()){
				cout << rank << endl;
				ch=false;
			}
			Us=score2.top();
			score2.pop();
			if(score2.top()!=Us)rank++;
		}
	}
	return 0;
}

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;
#define ll long long int
int main()
{
    fastio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<"\n";
    // if(a>=0 && b>=0 && c>=0 && d>=0)
    //     cout<<(max(a,b)*max(c,d))<<"\n";
    // else if(a<0 && b<0 && c<0 && d<0)
    //     cout<<(min(a,b)*min(c,d))<<"\n";
    // else if(a>0 && b>0 && c=<0 && d=<0)
    //     cout<<(min(a,b)*max(c,d))<<"\n";
    // else if(a<=0 && b<=0 && c>0 && d>0)
    //     cout<<(max(a,b)*min(c,d))<<"\n";
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int A,L,X;
  
  while(cin>>A>>L>>X) {
    double a = A, l = L, x = X;
    double th = acos(a/(2*l));
    double centM = (a*l*sin(th))/2;
    double ph = acos(l/(l+x));
    double sideM = l*(l+x)*sin(ph)/2;
    printf("%.10f\n", sideM + centM);
  }
  
  return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <stdlib.h>
#define MAX 200001
#define N 10000

int main (){
    unsigned short *A,*B;
    int C[N+1];
    int n,i,j;
    
    scanf("%d",&n);
    
    A=malloc(sizeof(short)*n+1);
    B=malloc(sizeof(short)*n+1);
    
    for(i=0;i<n;i++){
        scanf("%hu",&A[i+1]);
    }
    for(i=0;i<=N;i++){
        C[i]=0;
    }
    for(j=0;j<n;j++){
        C[A[j+1]]++;
    }
    for(i=1;i<=N;i++){
        C[i]=C[i]+C[i-1];
    }
    for(j=1;j<=n;j++){
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for(i=1;i<=n-1;i++){
        printf("%d ",B[i]);
    }
    printf("%d\n",B[n]);
    
    return 0;
}


Measured memory_bytes: 9588
weather = input("") 
if weather == "RRR":
   print(3)
elif weather == "SRR":
   print(2)
elif weather == "RSR":
   print(1)
elif weather == "RRS":
   print(2)
elif weather == "SSR":
   print(1)
elif weather == "RSS":
   print(1)
elif weather == "SRS":
   print(1)
elif weather == "SSS":
   print(0)


Measured memory_bytes: 8996
#include "iostream"
using namespace std;

int main()
{
	int n;
	cin >> n;
	char shurui[] = "SHCD";
	int card[52];
	for (int i = 0; i < 52; i++)
	{
		card[i] = 0;
	}
	for (int i = 0; i < n; i++)
	{
		int a; char b;
		cin >> b >> a;
		for (int j = 0; j < 4; j++)
		{
			if (b == shurui[j]) {
				card[13*j + a-1] = 1;
			}
		}
	}
	for (int i = 0; i < 52; i++)
	{
		if (card[i] == 0) {
			cout << shurui[i / 13] << " " << i % 13+1<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3012
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,x,y,ans;
int a[100002];
bool f[100002];
int main()
{
	scanf("%d%d",&n,&m);
	f[1]=1;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		a[x]--;
		a[y]++;
		if(f[x])f[y]=1;
		if(a[x]<0)f[x]=0;
	}
	for(int i=1;i<=n;i++)
		if(f[i])ans++;
	printf("%d",ans);
}

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

using namespace std;


int main(){
  int n;
  string event;
  int base=0;
  int inning=0;
  cin>>n;
  vector<int> point(n);
  int outnum=0;
  while(inning<n){
    cin>>event;
    if(event=="HIT"){
      base<<=1;
      base|=1;
      if(base&8){
        point[inning]++;
        base^=8;
      }
    }else if(event=="HOMERUN"){
      point[inning]+=1;
      for(int i=0;i<3;i++)
        point[inning]+=(base>>i)&1;
      base=0;
    }else if(event=="OUT"){
      outnum++;
      if(outnum>2){
        outnum=0;
        inning++;
        base=0;
      }
    }
  }
  for(int p:point)
    cout<<p<<endl;
}

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

struct doll{
    int h,r;
};

bool operator<(const doll& d1,const doll& d2){
    if(d1.h == d2.h){
        return d1.r > d2.r;
    }
    return d1.h < d2.h;
}

int dp[1001][1001] = {0};//h,r

int main() {

    while(1){

        for(int i=0;i<1001;i++){
            for(int j=0;j<1001;j++){
                dp[i][j] = 0;
            }
        }

        int n;

        cin >> n;

        if(n==0) break;

        int h,r;

        vector<doll> v;
        doll tmp;

        for(int i=0;i<n;i++){
            cin >> h >> r;
            tmp.h = h;
            tmp.r = r;
            dp[h][r] = 1;
            v.push_back(tmp);
        }

        int m;

        cin >> m;

        for(int i=0;i<m;i++){
            cin >> h >> r;
            tmp.h = h;
            tmp.r = r;
            dp[h][r] = 1;
            v.push_back(tmp);
        }

        /*for(int i=0;i<n+m;i++){
            cout << v[i].h << " " << v[i].r << endl;
        }*/

        sort(v.begin(),v.end());



        for(int k=0;k<n+m;k++) {
            for (int i = 1; i < v[k].h; i++) {
                for (int j = 1; j < v[k].r; j++) {
                    if (dp[i][j] != 0) {
                        dp[v[k].h][v[k].r] = max(dp[v[k].h][v[k].r], dp[i][j] + 1);
                    }
                }
            }
        }

        /*for(int i=0;i<=n+m;i++){
            for(int j=0;j<=n+m;j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }*/

        int ans = 0;

        for(int i=0;i<n+m;i++){
            //cout << dp[i] << endl;
            ans = max(dp[v[i].h][v[i].r],ans);
        }

        cout << ans << endl;


    }

    return 0;
}

Measured memory_bytes: 7008
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<fstream>
#include<functional>


using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;
using pr  = pair<int, int>;


int main() 
{
	int N;
	ll D;
	cin >> N >> D;

	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		ll X, Y;
		cin >> X >> Y;
		if (X*X + Y*Y <= D*D)
		{
			++ans;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int K, N;
int M, ans[312345];
ll dp[21];

int main() {
	cin >> K >> N;
	if ((K & 1) == 0) {
		M = N;
		ans[0] = K / 2;
		FOR(i, 1, M) ans[i] = K;
	}
	else {
		M = N;
		REP(i, M) ans[i] = (K + 1) / 2;
		int r = M - 1;
		for (int i = N / 2; i > 0; i--) {
			if (ans[r] > 1) {
				ans[r]--;
				FOR(j, r + 1, M) {
					ans[j] = K;
					r = j;
				}
			}
			else ans[r--] = 0;
		}
		for (int i = M - 1; i >= 0; i--) {
			if (ans[i] != 0) break;
			M = i;
		}
	}
	
	REP(i, M) printf("%d%c", ans[i], i == M - 1 ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 3456
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;



signed main() {
int X,N,frag=0,frag2=0,deg=0,min=0;
cin >> X >> N ;
vector<int> p(N);
REP(i,N){
    cin >> p[i];
}

while(frag==0){
    min = 0;
    frag = 0;
    frag2 = 0;
    REP(i,N){
if((X-deg)==p[i]){
        frag2=1;
        }
    }
if(frag2==0){
frag =1;
min =1;
break;
}
else frag2 = 0;

REP(i,N){
if((X+deg)==p[i]){
        frag2=1;
        }
    }
if(frag2==0){
frag =1;
break;
}
else frag2 = 1;

deg +=1;
}
if(min == 1){
answer(X-deg);
}
else answer(X+deg);
return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 998244353;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    int n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n) {
        cin >> d[i];
        if(i == 0 && d[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
        else if(i != 0 && d[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    map<ll,ll> mp;
    rep(i, n) {
        ++mp[d[i]];
    }
    ll ans = 1;
    repl(i, 1, n) {
        ans *= mp[d[i]-1];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10312