akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
struct Graph {
    std::vector<std::vector<Edge<Cost>>> graph;

    Graph(int n = 0) : graph(n) {}

    void span(bool direct, int src, int dst, Cost cost = 1) {
        graph[src].emplace_back(src, dst, cost);
        if (!direct) graph[dst].emplace_back(dst, src, cost);
    }

    std::vector<Edge<Cost>>& operator[](int v) { return graph[v]; }
    std::vector<Edge<Cost>> operator[](int v) const { return graph[v]; }

    int size() const { return graph.size(); }
};

template <class Cost>
std::vector<int> bfs(const Graph<Cost>& graph, int s) {
    std::vector<Cost> dist(graph.size(), -1);
    dist[s] = 0;
    std::queue<int> que;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (const auto& e : graph[v]) {
            if (dist[e.dst] != -1) continue;
            dist[e.dst] = dist[v] + e.cost;
            que.push(e.dst);
        }
    }

    return dist;
}

void solve() {
    int n, s, t;
    std::cin >> n >> s >> t;
    --s, --t;

    Graph<> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        graph.span(false, --u, --v);
    }

    auto sd = bfs(graph, s);
    auto td = bfs(graph, t);

    int ans = 0;
    for (int v = 0; v < n; ++v) {
        if (sd[v] >= td[v]) continue;
        ans = std::max(ans, td[v] - 1);
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <numeric>
#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int h,w;
    cin >> h >> w;
    vector<string> a;
    a.push_back(string(w+2,'.'));
    for(int i = 1;i<= h;i++)
    {
        string tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    a.push_back(string(w+2,'.'));
    rep(i, 1, h+1)
    {
        rep(j, 1, w+1)
        {
            if(a[i][j] == '#')
            {
                if(a[i-1][j] == '.' && a[i+1][j] == '.' && a[i][j-1] == '.' && a[i][j+1] == '.')
                {
                    Yes(0);
                    return 0;
                }
            }

        }
    }
    Yes(1);
}



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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int n,m; cin >> n >> m;
  vector<lint> a(n),b(n); for(int i=0;i<n;i++) { cin >> a[i] >> b[i]; }
  vector<lint> c(m),d(m); for(int i=0;i<m;i++) { cin >> c[i] >> d[i]; }

  for(int i=0;i<n;i++) {
    lint distmin=9999999999;
    int jmin=0;
    for(int j=0;j<m;j++) {
      lint cur = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(distmin > cur) {
        jmin = j;
        distmin = cur;
      }
    }
    printf("%d\n",jmin+1);
  }

  return 0;
}


Measured memory_bytes: 3644
N, M = map(int, input().split())
dp = [False] * N
dp[0] = True
count = [1] * N
for _ in range(M) :
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    dp[y] |= dp[x]
    count[x] -= 1
    count[y] += 1
    if count[x] == 0 :
        dp[x] = False
    
ret = 0
for i in range(N) :
    if dp[i] and count[i] > 0 :
        ret += 1
print(ret)

Measured memory_bytes: 47336
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,w[100004],v[100004],W;
ll dp[103][100004];
int main(){
	cin>>N>>W;
	for (ll i=0;i<N;i++) cin>>w[i]>>v[i];
	for (ll j=w[0];j<=W;j++) dp[0][j]=v[0];
	for (ll i=1;i<N;i++){
		dp[i][0]=dp[i-1][0];
		for (ll j=1;j<=W;j++){
			dp[i][j]=dp[i-1][j];
			if (j>=w[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	ll ans;
	for (ll i=0;i<=W;i++)
		ans=max(ans,dp[N-1][i]);
	cout<<ans;
}
	 

Measured memory_bytes: 82176
import * as fs from 'fs';

namespace AtCoder.abc159 {

    class ProgramB {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * akasaka
         * out
         * Yes
         */
        main(): void {

            const len: number = this.args[0].length;
            const s: string = this.args[0];

            const targer1: string = s.slice(0, (len - 1) / 2);
            const targer2: string = s.slice(((len + 3) / 2) - 1);

            if (targer1 === targer2) {
                console.log('Yes');
            } else {
                console.log('No');
            }
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new ProgramB(args);
    prg.main();
}




Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end() 
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
using namespace std;

int main()
{
	int n; cin >> n;
	vector<vector<pi>> xy(n);
	int a, x, y;
	rep(i, n)
	{
		cin >> a;
		xy[i] = vector<pi>(a);
		rep(j, a)
		{
			cin >> x >> y;
			xy[i][j] = {x - 1, y};
		}
	}
	int ans = 0;
	int bin = (1 << n) - 1;
	while(bin)
	{
		bool flag = false;
		rep(i, n)
		{
			if((1 << i) & bin)
			{
				rep(j, xy[i].size())
				{
					if((1 << xy[i][j].F) & bin)
					{
						if(xy[i][j].S == 0)
						{
							flag = true;
							break;
						}
					}
					else
					{
						if(xy[i][j].S == 1)
						{
							flag = true;
							break;
						}
					}
				}
				if(flag) break;
			}
		}
		if(!flag)
		{
			int temp = 0, temp_val = bin;
			while(temp_val)
			{
				temp += temp_val & 1;
				temp_val >>= 1;
			}
			ans = max(ans, temp);
		}
		bin--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    string S;
    cin >> S;
    if(S <= "2019/04/30"){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;



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

int D; int64_t G; cin >> D >> G;
VI p(D), c(D); rep(i, 0, D) cin >> p[i] >> c[i];
// 第 i 問を全部解いたときの点数．
VI comp(D); rep(i, 0, D) comp[i] = 100 * (i+1) * p[i] + c[i];

int mini = (int)1e9;

rep(bit, 0, (1<<D)){ // 全完する問題の2進表示
    int64_t point=0;
    int cnt = 0, last = D-1;
    rep(i, 0, D){ // 全完する問題の検索
        if (bit & (1<<i)){
            point += comp[i];
            cnt += p[i];
            last = i;
        }
    }
    // 全完した最高得点の問題の1つ低い点数の問題
    while (last > 0 && bit & (1<<last)) --last;
    for (int i = 0; i < p[last] && point < G; ++i) {
        point += 100 * (last+1);
        ++cnt;
    }
    if (point < G) continue;
    mini = min(mini, cnt);
}
cout << mini << "\n";
return 0;
}

// 境界，出力文字列 チェック



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

using namespace std;
#define ll long long
const int N=2e5+5,mod=1e9+7;
vector<int> adj[N];
ll ans=1;
int k;
void solve(int u,int p,int d,int c)
{
    ans*=(k-min(2,d)-c);
    ans%=mod;
    //cout<<u<<" "<<p<<" "<<d<<" "<<c<<endl;
   // cout<<(k-max(2,d)-c)<<endl;
    int cnt=0;
    for(auto v:adj[u])
        if(v!=p)
        {
            solve(v,u,d+1,cnt);
            cnt++;
        }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n>>k;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    solve(1,1,0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
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 ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //input
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = -INF;
    chmax(ans,a*c);
    chmax(ans,a*d);
    chmax(ans,b*c);
    chmax(ans,b*d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	ll R;
	cin >> R;
	cout << 3 * pow(R, 2);
}

Measured memory_bytes: 256
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n,m,x=input2()
CA=[]
ans=10**9

for _ in range(n):
	CA.append(input_array())

# ビット全探索
for i in range(2**n):
	bag=[]
	for j in range(n): #ビット全探索
		if (i>>j) & 1:
			bag.append(CA[j])
	enoughs=[0]*m #スキルがx以上身に付く数
	skills=[0]*m #身に付くスキルの合計
	money=0 #探索中の金額

	for b in bag:
		money+=b[0]
		for k in range(1,m+1):
			skills[k-1]+=b[k]
			if skills[k-1]>=x:
				enoughs[k-1]+=1
	if 0 not in enoughs: #スキルが充足
		if money<ans:
			ans=money #価格の更新
if ans==10**9:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 9200
#include<stdio.h>
#include<string.h>
int main(){
  char argv[1006];
  int argc;
  scanf("%s",argv);
  argc=strlen(argv);
  if(argv[argc-1]=='s'){
    printf("%s",strcat(argv,"es"));
   }
   else printf("%s",strcat(argv,"s"));
  
  return 0;
}


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

#define MAX_V 100000

int V, E;
vector<int> G[MAX_V];
vector<pair<int, int> > bridge;
bool visited[MAX_V];
int prenum[MAX_V];
int parent[MAX_V];
int lowest[MAX_V];
int timer, root;

void add_edge(int from, int to) {
  G[from].push_back(to);
  G[to].push_back(from);
}

void dfs(int u, int prev) {
    prenum[u] = timer;
    lowest[u] = timer;
    timer++;

    visited[u] = true;

    for(int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if(!visited[v]) {
        dfs(v, u);
        lowest[u] = min(lowest[u], lowest[v]);
        if(lowest[v] == prenum[v]) {
          if(u < v) bridge.push_back(make_pair(u, v));
          else bridge.push_back(make_pair(v, u));
        }
      } else if(v != prev) {
        lowest[u] = min(lowest[u], prenum[v]);
      }
    }

}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    add_edge(v1, v2);
  }

  for(int i = 0; i < V; i++) {
    visited[i] = false;
  }
  root = 0;
  timer = 1;
  dfs(root, -1);

  sort(bridge.begin(), bridge.end());
  for(int i = 0; i < bridge.size(); i++) {
    cout << bridge[i].first << " " << bridge[i].second << endl;
  }

}

Measured memory_bytes: 5340
#include<bits/stdc++.h>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;
void file(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

bool vis[20][20];
char ar[20][20];
int n , m , ans = 0 ;
bool valid(int x , int y){
    return (x>=0&&y>=0&&x<n&&y<m);
}

int bfs(int x , int y){
    memset(vis,0,sizeof vis);
    queue < pair < int , pair < int , int  > > > q ;
    q.push({0,{x,y}});
    vis[x][y]=1;
    int dist = 0 , x1 , y1;
    while(q.size()){
        dist = q.front().first;
        x1 = q.front().second.first ;
        y1 = q.front().second.second ;
        q.pop();

        for(int i = 0 ; i < 4 ;i++){
            int x2 = x1 + dx[i] , y2 = y1 + dy[i];

            if(valid(x2,y2)&&!vis[x2][y2]&&ar[x2][y2]=='.'){
                vis[x2][y2]=1;
                q.push({dist+1,{x2,y2}});
            }
        }
    }
    return dist;
}

int main(){//file();

    cin >> n >> m ;
    for(int i = 0 ; i < n ;i++)
        for(int k = 0 ; k < m ;k++)
            cin >> ar[i][k];

    for(int i = 0 ; i < n ;i++)
        for(int k = 0 ; k < m ;k++)
            if(ar[i][k]=='.')ans = max(bfs(i,k),ans);
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binpow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)
            res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m,i,j,sum=0,ans=0,k;
    cin>>n>>m;
    ll arr[n][m];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            cin>>arr[i][j];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            sum=0;
            for(k=0;k<m;k++)
                sum+=binpow(abs(arr[i][k]-arr[j][k]),2);
            if(ceil(sqrt(sum)==floor(sqrt(sum))))
                ans+=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(All(v));
    ll ans = 0;
    rep(i, k) ans += v[i];
    cout << ans <<endl;
    system("pause");
}


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

int main(){
  int N;
  scanf("%d", &N);
  vector<int> d(N);

  for(int i = 0; i < N; i++)
    cin >> d[i];

  sort(d.begin(), d.end());      //昇順

  int c1 = d[N/2-1];       //中央の左
  int c2 = d[N/2];           //中央の右

  cout << c2 - c1 << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

bool chsK(string s) {
	int n = s.length();
	if (n % 2 == 0) {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i - 1])return false;
		}
	}
	else {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i - 1])return false;
		}
	}
	return true;
}

int check(int X, int Y, int K, int J) {
	int t;
	if (K >= Y && J <= X)t = X - J + K - Y + 1;
	else if (K <= X || J >= Y) t = K - J;
	else if (J >= X && K <= Y)t = min(K - J, J - X + Y - K + 1);
	else if (K >= X && K <= Y)t = min(K - J, X - J + Y - K + 1);
	else if (J >= X && J <= Y)t = min(K - J, J - X + K - Y + 1);
	return t;
}



//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}


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


Measured memory_bytes: 256
Class Main
    Public Shared Sub Main()
        Dim N, A, B As Long
        Dim arr() As String
        arr = Split(Console.ReadLine())
        N = arr(0) : A = arr(1) : B = arr(2)
        Dim dv, rm As Long
        dv = Math.Floor(N / (A + B))
        rm = N Mod (A + B)
        Console.WriteLine(A * dv + Math.Min(A, rm))
    End Sub
End Class

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

int main() {

int N,M;
int A = 0;
cin >> N;
M = N;
  
  while(N/10 >= 0){
    A += N % 10;
    N = N/10;
    if (N < 10){
      A += N;
      break;
    }
  }
  if(M % A == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[105];
int main(){
	int n;
	scanf("%d",&n);
	long long ans = 0; 
	for(int i = 0; i < n-1; i++){
		scanf("%d",a+i);
	} 
	for(int i = 1; i < n-1; i++){
		ans+=min(a[i],a[i-1]);
	}
	ans+=(a[0]+a[n-2]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int INFTY = (1 << 21);
int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if(A + B <= 2 * C){
        cout << A * X + B * Y << endl;
    }
    else{
        if(X > Y){
            cout << min(2 * C * Y + (X - Y) * A, 2 * C * Y + (X - Y) * 2 * C) << endl;
        }
        else{
            cout << min(2 * C * X + (Y - X) * B, 2 * C * X + (Y - X) * 2 * C) << endl;
        }
    }
    return 0;
}

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

int main(){
  int n,k,q;cin>>n>>k;double maxp=0,ans=0;
  vector<double> p(n,0),cp(n+1,0);
  
  REP(i,n){
    double temp=0;cin>>temp;
    p.at(i)=temp;
    cp.at(i+1)=cp.at(i)+temp;
  }
  
  REP(i,n-k+1){
    if(maxp<cp.at(i+k)-cp.at(i)){
      maxp=cp.at(i+k)-cp.at(i);
      q=i;
    }
  }
  
  vector<double> ttl(1010,0);
  REP(i,1002) ttl.at(i+1)=ttl.at(i)+i+1;
  
  for(int i=q;i<q+k;i++){
    ans+=ttl.at(p.at(i))/(double)(p.at(i));
  }

  cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解答写し
int func(string s,string t){
  int ans=0;
  for(char c='a';c<='z';c++){
    bool founds=false,foundt=false;
    rep(i,s.length()){
      if(s[i]==c)founds=true;
    }
    rep(i,t.length()){
      if(t[i]==c)foundt=true;
    }
    if(founds&&foundt)ans++;
  }
  return ans;
}
int main() {
  int n; cin >>n;
  string s;cin>>s;
  int ans =0;
  rep(i,n){
    int tmp=func(s.substr(0,i),s.substr(i));
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int tmp[MAXN];
int A[MAXN];
int B[MAXN];

void mysort(int *vv,int sz,int di)
{
    int idx = -1;

    for(int i=0;i<sz;i++){
        if(vv[i]>=(1<<di)){
            idx = i;
            break;
        }
    }

    if(idx==-1)return;

    for(int i=idx;i<sz;i++)
        vv[i]%=(1<<di);

    int i=0,j=idx;
    int id = 0;

    for(int i=0;i<sz;i++)
        tmp[i] = 0;

    while(i<idx&&j<sz){
        if(vv[i]<=vv[j]){
            tmp[id] = vv[i];
            id++; i++;
        }
        else {
            tmp[id] = vv[j];
            id++; j++;
        }
    }

    if(i<idx){
        for(;i<idx;i++,id++)
            tmp[id] = vv[i];
    }
    if(j<sz){
        for(;j<sz;j++,id++)
            tmp[id] = vv[j];
    }

    for(int i=0;i<sz;i++)
        vv[i] = tmp[i];

    return;
}


int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++)
        cin>>A[i];
    for(int i=0;i<n;i++)
        cin>>B[i];

    sort(A,A+n);
    sort(B,B+n);

    int res = 0;

    int bx,by;

    for(int di = 28; di >=0 ;di--){

        x = n-1,y = n-1;
        bx = (1<<di),by = (1<<(di+1));

        for(int i=0;i<n;i++){
            while(x>=0&&B[x]+A[i]>=bx)x--;
            while(y>=0&&B[y]+A[i]>=by)y--;
            if((y-x)&1)res^=(1<<di);
        }

        x = n-1,y = n-1;
        bx = (1<<di)+(1<<(di+1)),by = (1<<(di+2));

        for(int i=0;i<n;i++){
            while(x>=0&&B[x]+A[i]>=bx)x--;
            while(y>=0&&B[y]+A[i]>=by)y--;
            if((y-x)&1)res^=(1<<di);
        }
        mysort(A,n,di);
        mysort(B,n,di);
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

// https://atcoder.jp/contests/abc141/tasks/abc141_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();//人数
		int K = sc.nextInt();//ラウンド開始時の得点
		int Q = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i=0;i<Q;i++) {
			list.add(sc.nextInt());
		}
		sc.close();


		//開始時のスコア
		int score[] = new int[N];
		Arrays.fill(score, K);

		int vector[] = new int[N];
		Arrays.fill(vector, Q);

		for(int i:list) {
			vector[i-1] = vector[i-1]-1;
		}

		for(int j=0;j<N;j++) {
			score[j] = score[j]-vector[j];
		}

		for(int i:score) {
			if(i<=0) {
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
		}
	}
}


Measured memory_bytes: 68396
#include <stdio.h>
#include <stdlib.h>
int Partition(int*,int,int);
int main() {
  int i,n,j;
  int *A;
  scanf("%d",&n);
  if(n<1 || n>100000) exit(8);
  A=malloc(n*sizeof(int));
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
      if(A[i]<0 || A[i]>100000) exit(8);
    }
  i = Partition(A,0,n-1);

  for(j=0;j<i;j++)
    {
      printf("%d ",A[j]);
    }
  printf("[%d] ",A[j]);
  for( j= j+1;j<n-1;j++)
    {
      printf("%d ",A[j]);
    }
  printf("%d\n",A[j]);
  return 0;
}
int Partition(int *A,int p,int r){
  int x,i,j,tmp;
  x = A[r];
  j=p-1;
  for(i=0;i<r-p;i++)
    {
      if(A[i]<=x)
	{
	  j++;
	  tmp = A[i];
	  A[i] = A[j];
	  A[j] = tmp;
	}
    }
  A[r] = A[j+1];
  A[j+1] = x;
  return j+1;
}
	  



Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int dp[100010],x[100000];
bool bo[100000];
signed main(){
	int n,m;
	cin>>n>>m;
	f(i,m){
		cin>>x[i];
		bo[x[i]]=true;
	}
	dp[0]=1;
	f(i,n){
		dp[i]%=mod;
		if(!bo[i]){
			dp[i+2]+=dp[i];
			dp[i+1]+=dp[i];
		}
	}
	cout<<dp[n]%mod<<endl;
}


Measured memory_bytes: 1920
n=int(input())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if n%2==0:
    a_min=(A[n//2-1]+A[n//2])/2
    b_max=(B[n//2-1]+B[n//2])/2
    print(int(1+(b_max-a_min)/0.5))
else:
    a_min=A[n//2]
    b_max=B[n//2]
    print(int(b_max-a_min)+1)

Measured memory_bytes: 25400
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int h, w, k;
int sum[12][1001];
string s[10];

int dfs(int x, vector<int> v) {
  int res = 1000000;
  if (x == h) {
    int p = 0;
    res = v.size() - 1;
    v.push_back(h);
    for (int i = 1; i <= w; i++) {
      int flag = 1;
      for (int j = 1; j < v.size(); j++) {
        if (sum[v[j]][i] - sum[v[j - 1]][i] - sum[v[j]][p] + sum[v[j - 1]][p] >
            k) {
          flag = 0;
          break;
        }
      }
      if (flag == 0 && i - 1 == p) {
        return 1000000;
      } else if (flag == 0) {
        p = i - 1;
        res++;
        int flag = 1;
        for (int j = 1; j < v.size(); j++) {
          if (sum[v[j]][i] - sum[v[j - 1]][i] - sum[v[j]][p] +
                  sum[v[j - 1]][p] >
              k) {
            flag = 0;
            break;
          }
        }
        if (flag == 0) {
          return 1000000;
        }
      }
    }
    v.pop_back();
    return res;
  }
  v.push_back(x);
  res = min(res, dfs(x + 1, v));
  v.pop_back();
  return min(res, dfs(x + 1, v));
}

int main() {
  vector<int> v;
  cin >> h >> w >> k;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      sum[i + 1][j + 1] = sum[i + 1][j];
      if (s[i][j] == '1') {
        sum[i + 1][j + 1]++;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      sum[i + 1][j + 1] += sum[i][j + 1];
    }
  }
  v.push_back(0);
  cout << dfs(1, v);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const long long MAX = 2e6+100;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	COMinit();
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	r1--; c1--;
	
	print((COM(r2+c2+2, r2+1)+MOD-COM(r2+c1+2, c1+1)+MOD-COM(r1+c2+2, r1+1)+COM(r1+c1+2, r1+1))%MOD)
	return 0;
}

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

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

    int N;
    cin >> N;
    int X[100] = {0};
    rep(i, N) {
        int x;
        cin >> x;
        X[i] = x; 
    }
    int ans = 10000000;
    rep(i, 100){
        int sum_hp = 0;
        rep(j, N){
            sum_hp += pow(X[j]-i-1, 2);
        }
        ans = min(ans, sum_hp);
    }
    cout << ans << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int>a(n);
    map<int,int> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        m.insert(make_pair(a[i],i));
    }
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(m[a[i]] % 2 != i % 2){
            ans++;
        }
    }
    int temp = ans % 2;
    ans /= 2;
    ans += temp;
    cout << ans;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

string s1, s2;

int main() {
    while (cin >> s1 >> s2) {
        if (s1 == "0") break;
        int num[11] = {0};
        int ex = 0;
        for (int i = 0; i < 4; ++i) {
            if (s1[i] == s2[i]) ++ex;
            num[s1[i]-'0']++;
            num[s2[i]-'0']++;
        }
        int same = 0;
        for (int i = 0; i < 10; ++i) if (num[i] == 2) ++same;
        cout << ex << " " << same-ex << endl;
    }
    return 0;
}


Measured memory_bytes: 1184
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;
map<ll, ll> mp;

void prime_factor(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
}

void solve() {
    FOR(i, 2, N + 1) prime_factor(i);
    ll ans = 1;
    EACH(m, mp) {
        ans *= (m.second + 1);
        ans %= ll(1e9 + 7);
    }
    cout << ans << endl;
}

int main() {
    cin >> N;
    solve();
    return 0;
}

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

int factrial(int64_t x){

  if(x==1) return 1;

  int64_t s=factrial(x-1);

  return (x*s)%1000000007;
}

//累乗を1000000007で割った余りをとり続ける
 
int main() {

  int N;

  cin>>N;

  cout << factrial(N) << endl;
  
  return 0;
}

Measured memory_bytes: 1792
<?php
// Your code here!
$N = trim(fgets(STDIN));
$value = trim(fgets(STDIN));
$array = explode(" ", $value);
$count = 0;
foreach ($array as $key => $val) {
    if (($key + 1) % 2 === 0) {
        continue;
    } else if ($val % 2 === 0) {
        continue;
    } else {
        $count++;
    }
};
echo $count;
?>


Measured memory_bytes: 16168
N = int(input())
a = list(map(int, input().split()))
A = 0
B = 0
for i in range(N):  # AとBの計算
    A += a[i] * a[i]
    B += a[i]
# print(A - ((B * B) / N))
for Y in range(-100, 101):
    temp = A - 2 * Y * B + N * Y * Y
    if Y == -100:
        ans = temp
    else:
        if temp <= ans:
            ans = temp
print(ans)


Measured memory_bytes: 3060
#include<cstdio>

using namespace std;

int main(){
    int a,b,c,d;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    int ans = 0;
    if (a > b) ans += b;
    else ans += a;
    if (c > d) ans += d;
    else ans += c;
    printf("%d\n", ans);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int N;
vector<string> S;

void dfs(int n, string s) {
  if(s.size()==N-1) {
    rep(i,n+2) S.push_back(s+(char)('a'+i));
  }
  else {
    rep(i,n+1) dfs(n,s+(char)('a'+i));
    dfs(n+1,s+(char)('a'+n+1));
  }
}

int main() {
  cin >> N;
  
  dfs(-1,"");
  sort(S.begin(),S.end());
  
  rep(i,S.size()) {
    cout << S[i] << endl;
  }
}

Measured memory_bytes: 7796
a = [input().split() for l in range(2)]
count = 0
N = int(a[0][0])
A = a[1]
ans = 0
for i in range(N-1):
    if int(A[i+1]) < int(A[i]):
        ans = ans + int(A[i]) - int(A[i+1])
        A[i+1] = A[i]
print(ans)
             


Measured memory_bytes: 25060
def mapt(fn, *args):
    return tuple(map(fn, *args))


def x(char):
    return int(char) if char.isdigit() else char


def sample(listseq):
    print(" ".join(str(i) for i in reversed(listseq)))




n = int(input())
a = mapt(int, input().split(" "))
sample(a)



Measured memory_bytes: 5600
a, b, c, d, e, f = map(int, input().split())

water = [False] * (f//100 + 1)
for i in range(0, len(water), a):
    water[i] = True
for i in range(len(water) - b):
    if water[i]:
        water[i + b] = True

sugar = [False] * ((f//100) * e + 1)
for i in range(0, len(sugar), c):
    sugar[i] = True
for i in range(len(sugar) - d):
    if sugar[i]:
        sugar[i + d] = True

# denominator: 分母, numerator: 分子
deno = a * 100
nume = 0

for i in range(1, len(water)):
    if water[i]:
        j = min([i*e, f - 100*i])
        while not sugar[j]:
            j -= 1
        i = 100 * i + j

        if nume * i < deno * j:
            deno = i
            nume = j

print(deno, nume)

Measured memory_bytes: 9252
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "random"
#include        "chrono"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
    cin >> n;

    cout << ( n >= 30 ? "Yes\n" : "No\n");
}

int32_t main()
{
    FAST;     
    int t=1; 
    // cin>>t;
    test(t) go();
}

 

Measured memory_bytes: 8332
#include <bits/stdc++.h>
#include <algorithm>
#define Freopen(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
#define int long long
using namespace std;
int n,a[200010],ans=0;
map<int,int>q;
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),q[a[i]+i]++,a[i]=i-a[i];
	sort(a+1,a+n+1);
	int sum=0,now;
	for(int i=1;i<=n;i++)
	{
		if(sum==0)sum++,now=a[i];
		else if(now==a[i])sum++;
		else if(now!=a[i])
		{
			ans+=sum*q[now];
			sum=1;
			now=a[i];
		}
	}
	ans+=sum*q[now];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 28016
N, K, Q = list(map(int, input().split()))
scores = [0] * N
for _ in range(Q):
    a = int(input())
    scores[a - 1] += 1

for s in scores:
    # 本来のスコアへの変換は
    # K - (Q-s) #もともと-他の人の正解数
    if K - (Q - s) <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 4680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    string N;
    cin >> N;

    int size = (int)N.size() - 1;
    if (N[size] == '2' || N[size] == '4' || N[size] == '5' || N[size] == '7' || N[size] == '9')
    {
        cout << "hon" << endl;
    }
    else if (N[size] == '0' || N[size] == '1' || N[size] == '6' || N[size] == '8')
    {
        cout << "pon" << endl;
    }
    else if (N[size] == '3')
    {
        cout << "bon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

//二項係数の計算
const int MAX = 510000;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
	fac[0] = fac[1] = 1;//階乗
	finv[0] = finv[1] = 1;//階乗の逆元
	inv[1] = 1;//逆元(1の逆元は1)
	for(int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;//累積積的な感じ
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;//inv[i] = iの逆元(mod mod)
		finv[i] = finv[i - 1] * inv[i] % mod;//階乗の逆元の計算
	}
}
ll COM(int n,int k){//二項係数の計算
	if(n < k){
		return 0;
	}
	if (n < 0 || k < 0){
		return 0;
	} 
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(ALL(a));

	COMinit();
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ans += (a[i] * (COM(i,k - 1) - COM(n - i - 1,k - 1)));
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12928
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

n, x = map(int, input().split())
xxx = list(map(lambda xn: abs(int(xn) - x), input().split()))
ans = xxx[0]
for i in range(1, n):
    ans = gcd(ans, xxx[i])
print(ans)

Measured memory_bytes: 20116
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;


int main(){
    int N,M;cin>>N>>M;
    vector<ll> A(N),S(N+1,0);
    map<int,ll> mp;
    mp[0]++;
    for(int i=0;i<N;++i) cin>>A[i];
    for(int i=0;i<N;++i){
        S[i+1]=S[i]+A[i];
        S[i+1]%=M;
        mp[S[i+1]]++;
    }
    ll ans=0;
    for(auto it:mp){
        ans+=(it.second)*(it.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8672
from heapq import heapify, heappush, heappop
from collections import defaultdict
import sys
input = sys.stdin.readline

def solve():
    N, Q = map(int, input().split())
    events = []
    for i in range(N):
        S, T, X = map(int, input().split())
        events.append((S-X-0.5, 1, X))
        events.append((T-X-0.5, 0, X))
    for i in range(Q):
        D = int(input())
        events.append((D, 2, i))

    events.sort()

    anss = [-1] * Q
    PQ = []
    isClosed = defaultdict(int)
    for tm, tp, x in events:
        if tp == 0:
            isClosed[x] = 0
        elif tp == 1:
            isClosed[x] = 1
            heappush(PQ, x)
        else:
            while PQ:
                if isClosed[PQ[0]] == 1:
                    anss[x] = PQ[0]
                    break
                heappop(PQ)

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 107456
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
	string S;
	cin>>S;
	int g=0;
	int p=0;
	int ans=0;
	fx(S.size()){
		if(p<g){
			if(S.at(x)=='g'){
				p++;
				ans++;
			}else{
              if(S.size()-x<=g-p){
                p++;
              }else{
				g++;
				ans--;
              }
			}
			
		}else{
			g++;
			if(S.at(x)=='p'){
				ans--;
			}
		}
	}
	ce(ans)
}

Measured memory_bytes: 512