akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>

int main(){
	int n, s[1000], sum;
	double d[1000], avg, sumsqdiv, stddiv;
	
	while(1){
		std::cin >> n;
		if(!n)
			break;
		sum = sumsqdiv = 0;
		for(int i=0; i<n; i++){
			std::cin >> s[i];
			sum += s[i];
		}
		avg = (double)sum / n;
		for(int i=0; i<n; i++){
			d[i] = s[i] - avg;
			sumsqdiv += d[i] * d[i];
		}
		stddiv = sqrt(sumsqdiv / n);
		std::cout << std::fixed << stddiv << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1236
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,len=0,n0001,n01,n10,ans=0,res,ach10,ach01;
pii a[100010],b[100010];
vector <pair <LL,pii> > v;
vector <pii> ch11,ch00;

void chmin(int i,int j)
{
	if(ch11[i].se==ch00[j].se) return;
	ans=min(ans,res+ch11[i].fi+ch00[j].fi);
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i].fi>>a[i].se;
		v.pb({a[i].fi,{i,0}});
		v.pb({a[i].se,{i,1}});
	}
	sort(v.begin(),v.end());
	rep(i,n)
	{
		ans+=v[i].fi;
		if(v[i].se.se==0) b[v[i].se.fi].fi=1;
		else b[v[i].se.fi].se=1;
	}
	//cout<<ans<<endl;
	//rep(i,3) cout<<b[i].fi<<' '<<b[i].se<<endl;
	rep(i,n)
	{
		if((b[i].fi==0&&b[i].se==0)||(b[i].fi==1&&b[i].se==1)) n0001++;else
		if(b[i].fi==0&&b[i].se==1) n01++;else
		n10++;
	}
	//cout<<(n0001>0)<<(n01==0||n10==0)<<(n0001==0)<<endl;
	//cout<<ans<<endl;
	if(n0001>0||(n0001==0&&(n01==0||n10==0)))
	{
		cout<<ans<<endl;
		rt0;
	}
	res=ans;
	ans=1e18;
	rep(i,n)
	{
		if(b[i].fi==1&b[i].se==0)
		{
			ch11.pb({a[i].se,i});
			ch00.pb({-a[i].fi,i});
			ach01+=a[i].se-a[i].fi;
		}
		else
		{
			ch11.pb({a[i].fi,i});
			ch00.pb({-a[i].se,i});
			ach10+=a[i].fi-a[i].se;
		}
	}
	sort(ch11.begin(),ch11.end());
	sort(ch00.begin(),ch00.end());
	chmin(0,0);
	chmin(0,1);
	chmin(1,0);
	ans=min(ans,min(res+ach01,res+ach10));
	cout<<ans<<endl;
	rt0;
}

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

using ll = long long;

const int MAXN = 3e5;
int N;
ll X;
ll B[MAXN], L[MAXN], U[MAXN];
ll tots[MAXN];

ll base;
int inds[MAXN];

ll get_cost(int ind, ll A) {
	if (A <= B[ind]) {
		return A * L[ind];
	} else {
		return B[ind] * L[ind] + (A - B[ind]) * U[ind];
	}
}

bool is_good(ll v) {
	// let's decide from which sequence we will take r first terms
	// then, we will take q largest sequences besides it
	
	int q = v / X;
	int r = v - q * X;
	
	ll sum = base;
	for (int i = 0; i < q; i++) {
		sum += tots[inds[i]];
	}
	for (int i = 0; i < N; i++) {
		ll nsum = sum + get_cost(inds[i], r);
		if (i < q) {
			nsum -= tots[inds[i]];
			nsum += tots[inds[q]];
		}
		if (nsum >= 0) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> B[i] >> L[i] >> U[i];
		base += -L[i] * B[i];
		tots[i] = B[i] * L[i] + (X - B[i]) * U[i];
	}

	iota(inds, inds + N, 0);
	sort(inds, inds + N, [&](int i, int j) { return tots[i] > tots[j]; });

	ll mi = -1, ma = X * N;
	while (ma - mi > 1) {
		ll md = (mi + ma) / 2;
		if (is_good(md)) {
			ma = md;
		} else {
			mi = md;
		}
	}
	cout << ma << endl;

	return 0;
}


Measured memory_bytes: 9600
M = 6400*4
mid = M//2
INF = 10**18

H,W = map(int, input().split())
As = []
for i in range(H):
    As.append(list(map(int, input().split())))
diffs = []
for i in range(H):
    bs = list(map(int, input().split()))
    diffs.append([abs(a-b) for a,b in zip(As[i],bs)])

# bitset高速化
# 初期値
dp = [[0]*W for j in range(H)]
dp[0][0] = 1 << (mid+diffs[0][0]) #プラスマイナス考慮して、下駄をはかせる
for i in range(H):
    for j in range(W):
        # 行方向
        if i+1 < H:
            d = diffs[i+1][j]
            dp[i+1][j] |= dp[i][j] >> d  
            dp[i+1][j] |= dp[i][j] << d  
        # 列方向
        if j+1 < W:
            d = diffs[i][j+1]
            dp[i][j+1] |= dp[i][j] >> d
            dp[i][j+1] |= dp[i][j] << d

ans = INF
for i in range(M):
    if dp[H-1][W-1] >> i & 1:
        # print(i-mid)
        ans = min(ans, abs(i-mid))
print(ans)

Measured memory_bytes: 20980
#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a,ll b)
{
  if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}

int  main()
{

   IOS;
   ll n,k;
   cin>>n>>k;
   map<ll,ll>freq,dup;
   ll ans=0,cnt=0;
   for(ll i=0;i<k;i++)
   {
      ll x;
      cin>>x;
      string y;
      cin>>y;
      if(dup[x]==1)
          continue;
        if(y=="AC")
        {
          dup[x]=1;
          ans++;
          cnt+=freq[x];
        }
        else
          freq[x]++;
   }
   cout<<ans<<" "<<cnt;
   }


Measured memory_bytes: 12800
t = [25, 10, 5, 1] 

ans _ [] = 0
ans n (t:ts) =
   let s = n `div` t 
       r = n `mod` t
   in
       s + (ans r ts)

main = do
    n <- getLine
    let n'= read n :: Int
        o = ans n' t
    print o



Measured memory_bytes: 3660
n = int(input())
S = list(map(lambda x: 1 if x=='E' else 0, list(input())))

for i in range(1, n):
    S[i] += S[i-1]

S.insert(0, 0)
ans = n
for i in range(1, n+1):
    c = i-S[i-1]-1
    # print(c)
    c += S[-1]-S[i]
    ans = min(ans, c)
print(ans)


Measured memory_bytes: 15184
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

max = 0
count = 0
(n-1).times do |i|
  if h[i] >= h[i+1]
    count += 1
  else
    count = 0
  end
  max = count if max < count
end

puts(max)

Measured memory_bytes: 9732
n, x, m = map(int, input().split())
mn = min(n, m)
P = []
sum_p = 0
X = [-1] * m
for i in range(mn):
    if X[x] > -1:
        cyc_len = len(P) - X[x]
        remain = P[X[x]]
        cyc = (sum_p - remain) * ((n - X[x]) // cyc_len)
        remain += P[X[x] + (n - X[x]) % cyc_len] - P[X[x]]
        print(cyc + remain)
        exit()
    P.append(sum_p)
    sum_p += x
    X[x] = i
    x = x*x % m
print(sum_p)

Measured memory_bytes: 13616
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  int k, x;
  cin >> k >> x;
  puts(k*500 >= x ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
 {
     int N,A[100]={0},i,j=0,k=0;
     scanf("%d",&N);
     for(i=0;i<N;i++){
       scanf("%d",&A[i]);
         if(A[i]%2==0){
           j++;
          if((A[i]%3==0)||(A[i]%5==0)) k++;
         }
     }
     if(j==k) printf("APPROVED\n");
     else     printf("DENIED\n");
   return 0;
 }

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

int main(void) {
    string a, b;
    int ans;
    bool flag = false;
    cin >> a >> b;
    ans = stoi(a + b);
    for (int i = 0; i * i <= ans; i++) {
        if (i * i == ans) flag = true;
    }
    cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int h,w;
  cin >> h >> w;
  
  vector<string>vec(h);
  rep(i,h) cin >> vec[i];
  vector<vector<bool>> used(h,vector<bool>(w,false));
  ll ans=0;
  
  queue<pair<P,char>>que;
  rep(i,h){
    rep(j,w){
      if(vec[i][j]=='#' && !used[i][j]){
        que.push(make_pair(P(i,j),'.'));
        used[i][j]=true;
        ll cntb=1,cntw=0;
        while(!que.empty()){
          auto q=que.front();
          que.pop();
          int y=q.first.first,x=q.first.second;
          char c=q.second;
          rep(k,4){
            int ny=y+dy[k],nx=x+dx[k];
            if(ny<0 || h<=ny || nx<0 || w<=nx )continue;
            if(vec[ny][nx]!=c || used[ny][nx])continue;
            used[ny][nx]=true;
            if(vec[ny][nx]=='.')que.push(make_pair(P(ny,nx),'#')),cntw++;
            else que.push(make_pair(P(ny,nx),'.')),cntb++;
          }
        }
        ans+=cntb*cntw;
      }
    }
  }
  cout << ans  << endl;
                 
                 
                 
                     
            
                            
  return 0;     
}


Measured memory_bytes: 512
n,  k = map(int, input().split())
a = list(map(int, input().split()))

# 内部の転倒数
ls = a[:]
inner = 0
while ls:
    x = ls.pop(0)
    inner += sum(1 if x > y else 0 for y in ls)

# 外部の転倒数
outer = 0
for x in a:
    for y in a:
        if x > y:
            outer += 1


print((inner*k + outer*(k-1)*k//2) % (10**9+7))

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

const int mod = 1e9 + 7;

int dp[200013][13];

signed main () {
	string s; 
	cin >> s;
	int n = s.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '?') {
			for (int j = 0; j < 10; ++j) {
				for (int r = 0; r < 13; ++r) 
					(dp[i + 1][(r * 10 + j) % 13] += dp[i][r]) %= mod;
			}
		}
		else {
			int j = s[i] - '0';
			for (int r = 0; r < 13; ++r)
				(dp[i + 1][(r * 10 + j) % 13] += dp[i][r]) %= mod;
		}
	}
	cout << dp[n][5] << '\n';
}


Measured memory_bytes: 6656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef pair<int,int> paii;
typedef long long ll;

int n, m, s;
int dp[100][5000];

int solve()
{
	CLR(dp);
	dp[0][0] = 1;
	
	FOR(i, 1, m+1)
		RFOR(j, 1, n*n+1)
			FOR(k, i, s+1)
			{
				dp[j][k] += dp[j-1][k-i];
				
				if(dp[j][k] >= 100000)
					dp[j][k] = dp[j][k]%100000;
			}
	
	return dp[n*n][s];
}

int main()
{
	while(cin >> n >> m >> s, (n||m||s))
	{
		cout << solve() << endl;
	}
		
	return 0;
}

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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll money=1000,stock=0;
  ll sa[n-1];
  for(int i=0;i<n-1;i++){
    sa[i]=a[i+1]-a[i];
  }
  for(int i=0;i<n-1;i++){
    if(sa[i]==0) continue;
    if(sa[i]<0) {
      money+=stock*a[i];
      stock=0;
    }
    if(sa[i]>0){
      ll temp=money;
      money=temp%a[i];
      stock+=temp/a[i];
    }
  }
  money+=stock*a[n-1];
  cout<<money<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
const int INF = 0x3f3f3f3f;
const int max_v = 10010;
const int max_e = 20010;
struct edge
{
    int to, dst, cost;
};
struct S
{
    int dst, to, cost;
    bool operator < (const S & ss) const {
        return dst > ss.dst;
    }
};
int n, m;
int d[max_v], value[max_v]; // v代表其父节点到其的费用
vector<edge> G[max_v];
void dijkstra(int s) {
    priority_queue<S> pq;
    for (int i = 1; i <= n; i++)  {
        d[i] = INF;
        value[i] = 0;
    }
    pq.push(S{0, s, 0});    
    while (!pq.empty()) {
        S p = pq.top(); pq.pop();
        int v = p.to;
        if (d[v] < p.dst) 
            continue;
        else if (d[v] > p.dst) {
            d[v] = p.dst;
            value[v] = p.cost;
            for (int i = 0; i < G[v].size(); i++) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.dst) {
                    pq.push(S{d[v] + e.dst, e.to, e.cost});
                }
            }
        } 
        else if (d[v] == p.dst) {
            value[v] = min(value[v], p.cost);
        }
    }
}

int main() {
    while (scanf("%d%d", &n, &m) != -1) {
        if (n == 0 && m == 0) break;
        int u, v, d, c, res;
        for (int i = 1; i <= n; i++) G[i].clear();
        for (int i = 0; i < m; i++) {
            scanf("%d%d%d%d", &u, &v, &d, &c);
            G[u].push_back(edge{v, d, c});
            G[v].push_back(edge{u, d, c});
        }
        dijkstra(1);
        res = 0;
        for (int i = 2; i <= n; i++) res += value[i];
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 5388
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private int N;
    private int[] x;
    private int[] y;
    private int[] t;

    public Main() {
	N = Integer.parseInt(scan.next());

	x = new int[N+1];
	y = new int[N+1];
	t = new int[N+1];
	
	for (int i = 0; i < N; i++) {
	    t[i+1] = Integer.parseInt(scan.next());
	    x[i+1] = Integer.parseInt(scan.next());
	    y[i+1] = Integer.parseInt(scan.next());
	}

	scan.close();
    }

    public final void answer() {

	String ans = "Yes";
	for (int i = 0; i < N; i++) {
	    int dx = distance(x[i], y[i], x[i+1], y[i+1]);
	    int dt = t[i+1] - t[i];
	    if( dx > dt || (dt - dx) % 2 != 0) {
		ans = "No";
		break;
	    }
	}

	System.out.println(ans);
	
    }

    private int distance(int x1, int y1, int x2, int y2) {
	return Math.abs(x1-x2) + Math.abs(y1-y2);
    }
}


Measured memory_bytes: 62848
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (N, M) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var xyz = Enumerable.Range(0, N).Select(i => ReadLine().Split(' ').Select(long.Parse).ToArray()).ToArray();
        
        static long Sum(long[] xyz, int p) => Enumerable.Range(0, 3).Select(i => ((p & 1 << i) == 0) ? xyz[i] : -xyz[i]).Sum();

        var ans = Enumerable.Range(0, 8).Select(i => xyz.Select(x => Sum(x, i)).OrderByDescending(x => x).Take(M).Sum()).Max();

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 30412
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    LL l, r;
    cin >> l >> r;
    REP(i, l, min(l+2020, r+1)){
        if(i%2019 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    LL mn = LLINF;
    REP(i, l, r)REP(j, i+1, r+1){
        chmin(mn, (1LL*i*j)%2019);
    }
    cout << mn << endl;
}

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

int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int answer = 0;
    for (int ir = 0; ir <= n / r; ir++)
    {
        for (int ig = 0; ig <= (n - ir * r) / g; ig++)
        {
            if ((n - ir * r - ig * g) % b == 0)
                answer++;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

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

	int n, x;
	cin >> n >> x;
	int small = 1000;
	for (int i = 0; i < n; i++) {
		int y;
		cin >> y;
		x -= y;
		small = min(small, y);
	}
	//~ cerr << x << ' ' << small << endl;
	
	cout << (n + x / small) << endl;
}


Measured memory_bytes: 256
import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

from operator import itemgetter

N, M = rrs()
A = rrs()

data = [rrs() for _ in range(M)]

data.sort(key=itemgetter(1), reverse=True)

p = 0
for d in data:
    if p <= N:
        A.extend([d[1]] * d[0])
    p += d[0]

A.sort(reverse=True)

print(sum(A[:N]))

Measured memory_bytes: 81704
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        int K = scan.nextInt();
        int x1 = scan.nextInt()-1;
        int y1 = scan.nextInt()-1;
        int x2 = scan.nextInt()-1;
        int y2 = scan.nextInt()-1;
        scan.nextLine();
        
        int[][] board = new int[h][w];
        for(int row = 0 ; row < h ; row++) {
            String s = scan.nextLine();
            for(int col = 0 ; col < w ; col++) {
                if(s.charAt(col) == '.') {
                    board[row][col] = 1000000009;
                } else {
                    board[row][col] = -1;
                }
            }
        }
        if(h == 0 || w == 0 || K == 0 || board[x2][y2] == -1) {
            System.out.println("-1");
            return;
        }
        
        Deque<int[]> queue = new LinkedList<>();
        queue.addLast(new int[]{x1,y1});
        board[x1][y1] = 0;
        int[][] dirs = {{0,1},{0,-1},{1,0},{-1,0}};
        while(!queue.isEmpty()) {
                int[] current = queue.removeFirst();
                int currDist = board[current[0]][current[1]];
                // get all unvisited neighbours of this cell.
                for(int[] dir : dirs) {
                    for(int k = 1 ; k <= K ; k++) {
                         int newX = current[0] + dir[0]*k;
                         int newY = current[1] + dir[1]*k;
                        if(newX < 0 || newY < 0 || newX >= h || newY >= w) break;
                        if(board[newX][newY] == -1) break;
                        if(board[newX][newY] < currDist + 1) break;
                        if(board[newX][newY] == 1000000009) {
                            board[newX][newY] = currDist + 1;
                            queue.addLast(new int[]{newX, newY});
                        }
                    }
                }
                // for(int i1 = 0 ; i1 < h ; i1++) {
                //     System.out.println(Arrays.toString(board[i1]));
                // }
        }
        
        System.out.println(board[x2][y2] == 1000000009 ? -1 : board[x2][y2]);
    }
}


Measured memory_bytes: 64536
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
	int k = Integer.parseInt(sc.next());
    
    int ans = n-k;
    
    if(k==1) { ans = 0;}
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	string s[101],ans="";
	cin>>n>>m; 
	for(int i=1; i<=n; i++) cin>>s[i];
	sort(s+1,s+n+1);
	for(int i=1; i<=n; i++) ans+=s[i];
	cout<<ans<<endl; 
	return 0;
}

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

const int MAXN = 2e5 + 5;

int N;
int a[MAXN];

int main() {
	scanf("%d", &N);
	N *= 2;
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
	
	sort(a, a + N);
	
	double sol = 0;
	for (int i = 0; i < N; i++)
		sol += (double)i * a[i];
	
	printf("%.10lf\n", sol / (N - 1));
	
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
    int days[] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
    int mo,dy;
    int day;
    
    while (scanf("%d %d", &mo, &dy)!=EOF){
        if (mo==0) break;
        day = 0;
        for (int i=1; i<mo; i++) day += days[i];
        day += dy;
        switch( day%7 ){
        case 1:
            printf("Thursday\n");
            break;
        case 2:
            printf("Friday\n");
            break;
        case 3:
            printf("Saturday\n");
            break;
        case 4:
            printf("Sunday\n");
            break;
        case 5:
            printf("Monday\n");
            break;
        case 6:
            printf("Tuesday\n");
            break;
        case 0:
            printf("Wednesday\n");
            break;
        }
    }
        
    return 0;
}

Measured memory_bytes: 1012
#include<iostream>

int swap = 0;

// Bubblesort
void bubblesort(int A[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				swap++;
				int tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
			}
		}
	}
}

// MAIN FUNCTION
int main()
{
	// Input
	int n;
	int A[100];
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> A[i];
	}
	
	// Bubble sort
	bubblesort(A, n);

	for (int i = 0; i < n; i++) {
		if (i)
			std::cout << " ";
		std::cout << A[i];
	}
	std::cout << std::endl;
	std::cout << swap << std::endl;

	return 0;
}

Measured memory_bytes: 3112
L = int(input())

def power2(i):
    power = 0
    while i > 1:
        i //= 2
        power += 1
    return power

r = power2(L)
N = r + 1
M = []
for i in range(1, N):
    M.append([i, i+1, 0])
    M.append([i, i+1, 2**(i-1)])

for i in range(N-1, 0, -1):
    if L - 2 ** (i-1) >= 2 ** r:
        M.append([i, N, L-2**(i-1)])
        L -= 2**(i-1)
M.sort()
print(N, len(M))
for i in M:
    print(i[0], i[1], i[2])

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

N=int(input())
B=sorted([list(map(int,input().split())) for i in range(N)],key=lambda x:x[0]+x[1])
#W+Sの順にソートすると無駄がない。

DP=[0]*(10**4+2)
#重さの合計がWのときの価値。
#W=10**4+1ならそれ以上更新されないので、W>=10**4+1以上のものはそこに置く

for w,s,v in B:
    
    if 10**4+1-w<=s:
        x=max(DP[10**4+1-w:s+1])+v
        if DP[-1]<x:
            DP[-1]=x

    if 10**4-w<s:
        for i in range(10**4-w,-1,-1):
            if DP[i+w]<DP[i]+v:
                DP[i+w]=DP[i]+v

    else:
        for i in range(s,-1,-1):
            if DP[i+w]<DP[i]+v:
                DP[i+w]=DP[i]+v        

print(max(DP))

Measured memory_bytes: 43868
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	s := next()
	fmt.Println(s[:3])

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  int A=1,B=0,C=0;
  char x = a.at(0);
  int k=0;
  while(k==0){
    if(x == 'a'){
      if(A < a.size()){
        A++;
        x = a.at(A-1);
        continue;
      }
      else {
        cout << 'A' << endl;
        break;
      }
    }
    else if(x == 'b'){
      if(B < b.size()){
        B++;
        x = b.at(B-1);
        continue;
      }
      else {
        cout << 'B' << endl;
        break;
      }
    }
    else if(x == 'c'){
      if(C < c.size()){
        C++;
        x = c.at(C-1);
        continue;
      }
      else {
        cout << 'C' << endl;
        break;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
    if(N==M){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

int const MAXL = 1e5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> V(N), W(N);
  for(int i = 0; i < N; ++i) std::cin >> V[i] >> W[i];
  int pN = std::min(N+1, 1024);
  auto dp = mk2d(pN, MAXL+1, (int)-1);
  std::fill_n(dp[0].begin(), MAXL+1, 0);
  auto calc = [&](auto&& f, int i)->void {
    int pi = i/2;
    if(dp[pi][0] < 0) f(f, pi);
    // don't use V[i-1], W[i-1]
    std::copy_n(dp[pi].begin(), MAXL+1, dp[i].begin());
    // use V[i-1], W[i-1];
    for(int w = MAXL; w >= W[i-1]; --w) {
      int nv = dp[pi][w-W[i-1]] + V[i-1];
      if(nv > dp[i][w]) dp[i][w] = nv;
    }
  };
  int Q; std::cin >> Q;
  for(int q = 0; q < Q; ++q) {
    int u, L; std::cin >> u >> L;
    if(u < pN) {
      if(dp[u][0] < 0) calc(calc, u);
      std::cout << dp[u][L] << "\n";
      continue;
    }
    std::vector<int> nodes;
    while(u >= pN) {
      nodes.push_back(u);
      u /= 2;
    }
    if(dp[u][0] < 0) calc(calc, u);
    int ans = 0;
    int S = (1<<nodes.size());
    for(int s = 0; s < S; ++s) {
      int sumv = 0, sumw = 0;
      for(int i = 0; i < nodes.size(); ++i) if((1<<i)&s) {
        sumv += V[nodes[i]-1];
        sumw += W[nodes[i]-1];
      }
      if(sumw > L) continue;
      ans = std::max(ans, sumv + dp[u][L - sumw]);
    }
    std::cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 407096
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

ll n,W;

int main(){
    cin >> n >> W;
    vector<ll> w(n);
    vector<ll> v(n);
    vector<vector<ll>> a(4);
    REP(i,n){
        cin >> w[i] >> v[i];
        a[w[i]-w[0]].push_back(v[i]);
    }
    REP(i,4){
        sort(all(a[i]),greater<>());
    }
    vector<vector<ll>> s(4);
    REP(i,4){
        s[i].push_back((ll)0);
        REP(j,a[i].size()){
            s[i].push_back(s[i].back()+a[i][j]);
        }
    }
    ll res = 0;
    REP(i,a[0].size()+1){
        REP(j,a[1].size()+1){
            REP(k,a[2].size()+1){
                REP(l,a[3].size()+1){
                    if((w[0]*(i+j+k+l)+j+k*2+l*3)<=W){
                        ll val = s[0][i]+s[1][j]+s[2][k]+s[3][l];
                        chmax(res,val);
                    }
                }
            }
        }
    }
    put(res);
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
root1 = set()
root2 = set()

for _ in range(m):
    a,b = map(int,input().split())
    if a==1:
        root1.add(b)
    if b ==n:
        root2.add(a)

for root in root1:
    if root in root2:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Measured memory_bytes: 18936
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	map <int, int> cnt;
	int n, m;
	scanf("%d", &n);
	while (n--) {
		int a;
		scanf("%d", &a);
		cnt[a]++;
	}
	scanf("%d", &m);
	while (m--) {
		int a;
		scanf("%d", &a);
		if (cnt[a]) cnt[a]--;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=3000;
const int MAXM=MAXN-1;

int n;
int val[MAXN];
int ghead[MAXN],gnxt[2*MAXM],gto[2*MAXM];
bool win[MAXN];

pair<int,int> o[MAXN];

void solve() {
	REP(i,n) o[i]=MP(val[i],i); sort(o,o+n);
	REP(i,n) {
		int at=o[i].second;
		win[at]=false;
		for(int x=ghead[at];x!=-1;x=gnxt[x]) {
			int to=gto[x]; if(val[to]>=val[at]) continue;
			if(!win[to]) win[at]=true;
		}
		//printf("%d -> %s\n",at+1,win[at]?"win":"lose");
	}
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%d",&val[i]);
	REP(i,n) ghead[i]=-1;
	REP(i,n-1) {
		int a,b; scanf("%d%d",&a,&b); --a,--b;
		gnxt[2*i+0]=ghead[a]; ghead[a]=2*i+0; gto[2*i+0]=b;
		gnxt[2*i+1]=ghead[b]; ghead[b]=2*i+1; gto[2*i+1]=a;
	}
	solve();
	bool first=true; REP(i,n) if(win[i]) { if(first) first=false; else printf(" "); printf("%d",i+1); } puts("");
}

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


Measured memory_bytes: 384
// This is the template example file for programming//
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

Vll a;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N; 
    cin >> N;
    a.rs(N);
    rep(i,0,N) cin >> a[i];
    ll cur=1;
    ll res=0;
    rep(i,0,N){
        if(a[i]!=cur) res++;
        else cur++;
    }
    if(cur==1) COUT(-1);
    else COUT(res);
}

Measured memory_bytes: 1792
#pragma GCC target ("avx,avx2,fma")
#pragma GCC optimize ("unroll-loops")

#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    const int MOD = 1000000007;
    int n, r;
    char p;
    cin >> n;
    int upbound = (1 << n);
    vector<int> g(n), dp(upbound);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            cin >> p;
            if(p=='1')
            g[i] |= (1 << j);
        }
    dp[0] = 1;
    for (int x = 1; x < upbound; ++x) {
        p = __builtin_popcount(x), r = 0;
        for (int y = x & g[p - 1]; y; y &= y - 1)
        {
            r += dp[x & ~(y & -y)];
            if (r >= MOD) r -= MOD;
        }
        dp[x] = r;
    }
    cout << dp[upbound - 1];
}

Measured memory_bytes: 11344
a = input()
b = input()

lena=len(a)
lenb=len(b)

s = [a,b]
s.sort()

ans = 0
if lena>lenb:
  ans = a
elif lena<lenb:
  ans = b
elif s[0] == s[1]:
  ans = 0
else:
  ans = s[1]
  
if ans==0:
  print("EQUAL")
elif ans==a:
  print("GREATER")
else:
  print("LESS")


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

int main(){
    int a;
    char s[11];
    int ans;

    //input
    cin >> a >> s;

    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率]
ll mod = 1e9 + 7;

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓

ll n, m, a[100100];
bool J[100100];





int main() {
	cin >> n >> m;
	rep(i, n + 1) J[i] = true;
	rep(i, m) {
		ll tmp;
		cin >> tmp;
		J[tmp] = false;
	}
	a[0] = 1;

	if (J[1]) a[1] = 1;
	else a[1] = 0;

	REP(i, 2, n + 1) {
		if (J[i]) a[i] = (a[i - 1] + a[i - 2]) % mod;
		else a[i] = 0;
	}
	cout << a[n]<< endl;

	return 0;
}



Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	set<int> s;
	rep(i, n) {
		int k;
		cin >> k;
		s.insert(k);
	}
	cout << s.size() << endl;
}

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

using namespace std;

int main(){
	int number_of_people;
	int number_of_food_item;
	cin >> number_of_people >> number_of_food_item;

	int cnt_of_foodliked[number_of_food_item + 1] = {0};
	for(int i = 0; i < number_of_people ; i = i + 1){
		int his_prefereferences;
		cin >> his_prefereferences;
		for(int j = 0; j < his_prefereferences; j = j + 1){
			int food_he_likes;
			cin >> food_he_likes;
			cnt_of_foodliked[food_he_likes] = cnt_of_foodliked[food_he_likes] + 1;
		}
	}
	int ans = 0;
	for(int food_item = 1; food_item <= number_of_food_item; food_item++){
		//cout << food_item << " " << cnt_of_foodliked[food_item] << '\n'; 
		if(cnt_of_foodliked[food_item] == number_of_people){
			ans = ans + 1;
		}
	}
	cout << ans << '\n';

}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>



#include <assert.h>


using namespace std;
class A {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    int n;
    in >> n;
    vector<long long int> a(3 * n);
    for(int i = 0; i < a.size(); ++i){
      in >> a[i];
    }
    sort(a.begin(), a.end(), greater<long long int>());
    long long int sum = 0;
    for(int i = 0; i < n; ++i){
      sum += a[1 + 2 * i];
    }
    out << sum << endl;
	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2560
n, d = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
t = 0
for i in range(n):
  for j in range(i+1, n):
    s = 0
    for b, c in zip(a[i], a[j]):
      s += (b - c) ** 2
    if s ** 0.5 == int(s ** 0.5):
      t += 1
print(t)

Measured memory_bytes: 9376
#include <stdio.h>
int main(){
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if( (a==b && a!=c) || (a==c && a!=b) || (b==c && a!=c) ){ printf("Yes\n"); }
  else													  { printf("No\n");  }
  return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int x,y;
    cin >> x >> y;

    bool ans=false;
    set<int> group1={1,3,5,7,8,10,12},group2={4,6,9,11},group3={2};
    if(group1.find(x)!=group1.end() && group1.find(y)!=group1.end())ans=true;
    if(group2.find(x)!=group2.end() && group2.find(y)!=group2.end())ans=true;
    if(group3.find(x)!=group3.end() && group3.find(y)!=group3.end())ans=true;

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3596
def main():

    A,B = map(int,input().split())
    if A==0 or B==0:
        print("IMPOSSIBLE")
        exit()
    if A%2!=B%2:
        print("IMPOSSIBLE")
        exit()

    small = min(A,B)
    large = max(A,B)
    large -= small
    print(int(large/2+small))




if __name__== "__main__":
    main() 


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	int k = n;
	int sum = 0;
	while (k > 0) {
		sum += k % 10;
		k /= 10;
	}
	if (n % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();

		if( (a.equals("H") && b.equals("H")) || a.equals("D") && b.equals("D")) {
			System.out.println("H");
		}else {
			System.out.println("D");
		}
}
}


Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main() {
	string s;
	int i;
	cin >> s;
	int k;
	if (s[0] == 'B') {
		k = 0;
	}
	else {
		k = 1;
	}
	int  counter = 0;
	for (i = 1; i < s.size(); i++) {
		if ((s[i] == 'W')&&(k == 0)) {
			k = 1;
			counter++;
		}
		if ((s[i] == 'B') && (k == 1)) {
			k = 0;
			counter++;
		}
	}

	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::greater<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  if (n == m) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 892
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);
    int cnt = 0;
    while (cnt < k) {
        vector<int> s(n+1);
        rep(i, n) {
            int l = i - a[i];
            int r = i + a[i]+1;
            if (l < 0) l = 0;
            if (r > n) r = n;
            s[l] += 1;
            s[r] += -1;
        }
        ll tmp = 0;
        bool flag = true;
        rep(i, n) {
            a[i] = tmp + s[i];
            if (a[i] != n) flag = false;
            tmp = a[i];
        }
        if (flag) break;
        cnt++;
    }
    rep(i, n) {
        printf("%lld ", a[i]);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 20;
vector <int> gr[maxn], ans[maxn];
int n, m, vis[maxn];
void dfs(int v, int u) {
	vis[v] = 1;
	for (int i: gr[v]) {
		if (!vis[i]) {
			dfs(i , v);
			if (ans[i].size() % 2)
				ans[i].push_back(v);
			else
				ans[v].push_back(i);
			
		}
		else if (i != u) {
			if (i > v)
				ans[v].push_back(i);
		}
	}
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	
	if (m % 2)
		cout << -1 << endl;
	else {
		dfs(1, 0);
	}
	for (int i = 1; i <= n; i++)
		for (int j: ans[i])
			cout << i << " " << j << endl;
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  scanf("%d", &N);
  ll a[N];
  for (int i = 0; i < N+1; ++i) {
    scanf("%lld", &a[i]);
  }
  ll b[N];
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &b[i]);
  }

  ll ans = 0;

  FOR(i,0,N-1){
    ll damage1 = min(a[i],b[i]);
    ans += damage1;
    a[i] -= damage1;
    b[i] -= damage1;

    ll damage2 = min(a[i+1],b[i]);
    ans += damage2;
    a[i+1] -= damage2;
    b[i] -= damage2;
  }

  cout << ans << endl;

}



Measured memory_bytes: 1792
//for syt

#include<bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
	int n,k;
	vector<int>v;
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
	}
	for(int i=1;i<=n-k;i++) {
		if(a[i]<a[i+k]) {
			cout<<"Yes";
			puts("");
		}
		else {
			cout<<"No";
			puts("");
		}
	}
	return 0;
}


Measured memory_bytes: 4408