akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int N;
    cin >> N;
    int s = sqrt(N);
    int cnt = 0;
    int arr[N + 1];
    fill(arr, arr + N + 1, 0);
    for (int x = 1; x <= s; ++x) {
        for (int y = 1; y <= s; ++y) {   // x^2 + y^2 + + z^2 + xy + xz + yz = N
            for (int z = 1; z <= s; ++z) {
                int val = x*x + y*y + z*z + x*y + y*z + x*z;
                if (val > N) continue;
                ++arr[val];
            }
        }
    }
    for (int i = 1; i <= N; ++i) cout << arr[i] << "\n";
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


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

int N;

int main(){

	cin >> N;
  	
  	string W[N];
  	
  	int flag1 = 0;
  	int flag2 = 0;
  	
  	for(int i = 0; i < N ; i++) cin >> W[i];
  
	//同じ言葉がないかどうかのチェック
  	for(int i = 0; i < N ; i++){
    	
      	for(int j = 0; j < N ; j++){
        
        	if(W[i] == W[j] && i != j) flag1++;
        
        }
    
    }
  	
  	//最後と最初が同じ文字の判定
  	for(int k = 0; k < N-1; k++){
      
    	if(W[k][W[k].size()-1] !=  W[k+1][0])  flag2++;
    	//cout << W[k][0] << endl;
      	//cout <<  W[k+1][W[k+1].size()-1] << endl;
      	
    }
  	
    //cout << flag1 << endl;
    //cout << flag2 << endl;
  
  	if( flag1 == 0 && flag2 ==0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>A>>B;
    ll res = 0;
    res += max(0LL, (4 - A) * 100000);
    res += max(0LL, (4 - B) * 100000);
    if(A == 1 && B == 1) res += 400000;
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


void eating_symbols_easy()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 4; ++i)
  {
    if (s[i] == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << "\n";
}


void multiple_of_2_and_n()
{
  int n;
  cin >> n;

  if (n % 2 == 0) cout << n << "\n";
  else cout << 2 * n << "\n";
}


int main()
{
  //eating_symbols_easy();
  multiple_of_2_and_n();
}

Measured memory_bytes: 256
from itertools import product
from heapq import heappush, heappop

class Dijkstra:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]

    def add_edge(self, init, end, weight, undirected=False):
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
    
    def distance(self, s):
        INF = float('inf')
        self.dist = [INF] * self.N # the distance of each vertex from s
        self.prev = [-1] * self.N # the previous vertex of each vertex on a shortest path from s
        n_visited = 0 # #(visited vertices)
        heap = []
        heappush(heap, (0, -1, s))
        while heap:
            d, p, v = heappop(heap)
            if self.dist[v] != INF: continue # (s,v)-shortest path is already calculated
            self.dist[v] = d; self.prev[v] = p
            n_visited += 1
            if n_visited == self.N: break
            for u, c in self.E[v]:
                if self.dist[u] != INF: continue
                temp = d + c
                if self.dist[u] > temp: heappush(heap, (temp, v, u))
        return self.dist
    
    def shortest_path(self, t):
        P = []
        prev = self.prev
        while True:
            P.append(t)
            t = prev[t]
            if t == -1: break
        return P[::-1]

H, W = map(int, input().split())
dijkstra = Dijkstra(H * W)

def vtx(i, j): return i*W + j
def coord(n): return divmod(n, W)

grid = [input() for _ in range(H)] # |string| = W
E = [[] for _ in range(H * W)]
ans = 0 if grid[0][0] == '.' else 1
for i, j in product(range(H), range(W)):
    v = vtx(i, j)
    check = [vtx(i+dx, j+dy) for dx, dy in [(1, 0), (0, 1)] if i+dx <= H-1 and j+dy <= W-1]
    for u in check:
        x, y = coord(u)
        if grid[i][j] == '.' and grid[x][y] == '#':
            dijkstra.add_edge(v, u, 1)
        else:
            dijkstra.add_edge(v, u, 0)
dist = dijkstra.distance(0)
ans += dist[vtx(H-1, W-1)]
print(ans)

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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(101, 0);
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        p[x]++;
    }
    int up = 101;
    for(int i = X; i < 101; i++) {
        if(p[i] == 0) {
            up = i;
            break;
        }
    }
    int down = 101;
        for(int i = X; 0 <= i; i--) {
        if(p[i] == 0) {
            down = i;
            break;
        }
    }
    if(up == down && down == 101) {
        cout << X << endl;
    }
    if(abs(up - X) - abs(down - X) == 0) {
        cout << down << endl;
        return 0;
    }
    int res = 0;
    if(abs(up - X) < abs(down - X)) {
        res = up;
    } else {
        res = down;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//ifstream in("input.txt");
	//cin.rdbuf(in.rdbuf());
	ll x,t;
	cin >> x >> t;
	cout << TO(t>=x,0,x-t) << endl;
}


Measured memory_bytes: 256
n, h = gets.strip.split.map(&:to_i)
a = readlines.map {|line| line.strip.split.map(&:to_i) }.sort

categorized = a.group_by(&:first)

usual = categorized[categorized.keys.max].sort.first

tmp_h = h
result = 0
a.select {|e| e.last>usual.first }.map(&:last).sort.reverse.each do |thr|
  tmp_h -= thr
  result+=1
  if tmp_h<=0
    p result
    exit
  end
end

# 投げダメージだけだと倒せないので投げと振りで倒す
result = 0

throws = a.select {|e| e.last>usual.first }.map(&:last)
throws_dmg = throws.inject(0, :+)
h -= throws_dmg
result += throws.length

result += (h/usual.first.to_f).ceil

p result


Measured memory_bytes: 23664
// ※※※ 解答不能 ※※※
// snuke氏.
// https://atcoder.jp/contests/abc164/submissions/12452255
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int MAX_V = 55;
const int MAX_S = MAX_V * MAX_V;
const LL INF = 1e18;

struct Edge{
    int to, a, b;
    Edge(int to, int a, int b) : to(to), a(a), b(b) {}
};

struct Data{
    int v, s;
    LL x;
    Data(int v, int s, LL x) : v(v), s(s), x(x) {}
    bool operator < (const Data& a) const {
        return x > a.x;
    }
};

vector<Edge> g[MAX_V];
LL dist[MAX_V][MAX_S + 5];

int main(){
    int n, m, s;
    scanf("%d %d %d", &n, &m, &s);
    rep(i, m){
        int u, v, a, b;
        scanf("%d %d %d %d", &u, &v, &a, &b);
        --u; --v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    rep(i, n) rep(j, MAX_S + 5) dist[i][j] = INF;
    s = min(s, MAX_S);
    priority_queue<Data> q;
    auto push = [&](int v, int s, LL x){
        if(s < 0)           return;
        if(dist[v][s] <= x) return;
        dist[v][s] = x;
        q.emplace(v, s, x);
    };
    vector<int> c(n), d(n);
    rep(i, n) scanf("%d %d", &c[i], &d[i]);
    push(0, s, 0);
    while(!q.empty()){
        Data hoge = q.top();
        q.pop();
        int v = hoge.v, s = hoge.s;
        LL x = hoge.x;
        if(dist[v][s] != x) continue;
        {
            int ns = min(s + c[v], MAX_S);
            push(v, ns, x + d[v]);
        }
        for(Edge e : g[v]) push(e.to, s - e.a, x + e.b);
    }
    repx(i, 1, n){
        LL ans = INF;
        rep(j, MAX_S + 5) ans = min(ans, dist[i][j]);
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 6564
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//A
		/*
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b < a)
			System.out.println(a-1);
		else
			System.out.println(a);
			*/
		//B
		/*
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		for(int i = 0 ; i < k ; i++){
			int max = a;
			int max_index = 0;
			if(max < b){
				max = b;
				max_index = 1;
			}
			if(max < c){
				max = c;
				max_index = 2;
			}
			switch(max_index){
				case 0: a*=2;break;
				case 1: b*=2;break;
				case 2: c*=2;break;
			}
		}
		System.out.println(a+b+c);
		/*
		//C
		/*
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] s = new String[h];
		for(int i = 0 ; i < h ; i++){
			s[i] = sc.next();
		}
		boolean successflag = true;
		for(int i = 0 ; i < h ; i++){
			for(int j =0 ; j < w ; j++){
				boolean flag = false;
				if (s[i].charAt(j) == '#') {
					if (i > 0) {//上
						if (s[i - 1].charAt(j) == '#')
							flag = true;
					}
					if (i < h - 1) {//下
						if (s[i + 1].charAt(j) == '#')
							flag = true;
					}
					if (j > 0) {
						if (s[i].charAt(j - 1) == '#')
							flag = true;
					}
					if (j < w - 1) {
						if (s[i].charAt(j + 1) == '#')
							flag = true;
					}
					if (!flag)
						successflag = false;
				}
			}
		}
		if(successflag)
			System.out.println("Yes");
		else
			System.out.println("No");
			*/
		//D
		int n = sc.nextInt();
		int[] ans = new int[n];
		int counter = 0;
		for(int i = 6 ; i < 55555; i++){
			if(i%5 == 1){
				if(check(i)){
					ans[counter] = i;
					counter++;
				}
			}
			if(counter == n)
				break;
		}
		if(counter == n){
			for(int j = 0 ; j < n ; j++){
				System.out.print(ans[j]+" ");
			}
			System.out.println();
		}
		else
			System.out.println("error!");
	}

	public static boolean check(int x){
		boolean ans = true;
		for(int i = 2 ; i < x ; i++){
			if(x%i == 0)
				ans = false;
		}
		return ans;
	}
}


Measured memory_bytes: 21844
n = int(input())
B = list(map(int, input().split()))

a = [-1] * n

for i, b in enumerate(B):
    if a[i] > B[i]:
        a[i] = b
        a[i+1] = b
    elif a[i] != -1:
        a[i+1] = b
    elif a[i] == -1:
        a[i] = b
        a[i+1] = b

print(sum(a))

Measured memory_bytes: 62032
import heapq
v,e=map(int,input().split())
edge=[]
for i in range(e):
  s,t,w=map(int,input().split())
  edge.append([w,s,t])
heapq.heapify(edge)
class UnionFind:
  def __init__(self,n):
    self.n=n
    self.r=[i for i in range(n)]
    self.rank=[1 for i in range(n)]
    self.cost=0
  def find(self,x):
    if x==self.r[x]:
      return x
    else:
      self.r[x]=self.find(self.r[x])
      return self.r[x]
  def union(self,x,y,c):
    rx=self.find(x)
    ry=self.find(y)
    if rx==ry:
      return
    if self.rank[ry]>self.rank[rx]:
      rx,ry=ry,rx
    self.r[ry]=rx
    self.rank[rx]+=self.rank[ry]
    self.cost+=c
uf=UnionFind(v)
while edge:
  path=heapq.heappop(edge)
  if uf.find(path[1])==uf.find(path[2]):
    continue
  uf.union(path[1],path[2],path[0])
print(uf.cost)


Measured memory_bytes: 24904
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007

template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long K;
    cin >> K;
    ll total = 0;
    for(size_t i=1;i<=K; i++)
    {
        for(size_t j=1;j<=K; j++)
        {
            for(size_t k=1;k<=K; k++)
            {
                vector<ll> num={(ll)i, (ll)j, (ll)k};
                total += ngcd(num);
            }
        }
    }
    cout << total << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

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


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

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

bool matches_pattern(std::string S_dash, std::string T, int start_index) {
    if (start_index + T.length() > S_dash.length()) {
        return false;
    } else {
        for (int i = 0; i < T.length(); i ++) {
            if (S_dash[start_index + i] == '?') {
                continue;
            } else if (S_dash[start_index + i] == T[i]) {
                continue;
            } else {
                return false;
            }
        }
        return true;
    }
}

int main() {
    std::string S_dash;
    std::string T;
    std::cin >> S_dash;
    std::cin >> T;

    std::vector<std::string> candidates;
    for (int i = S_dash.length() - T.length(); i >= 0; i --) {
        if (matches_pattern(S_dash, T, i)) {
            std::string S = S_dash;
            std::replace(S.begin(), S.end(), '?', 'a');
            S.replace(i, T.length(), T);
            candidates.push_back(S);
        }
    }

    if (!candidates.empty()) {
        std::cout << *std::min_element(candidates.begin(), candidates.end()) << std::endl;
    } else {
        std::cout << "UNRESTORABLE" << std::endl;
    }
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

class UnionFind:
    def __init__(self, size, m):
        self.m = m
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if s1 >= self.m:
                self.table[s1] = s2
            elif s2 >= self.m:
                self.table[s2] = s1
            elif self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    rr = []

    def f():
        n,m,t,p = LI()
        if n == 0:
            return

        dc = [LI() for _ in range(t)]
        xy = [LI() for _ in range(p)]

        ux = UnionFind(n*n, n)
        uy = UnionFind(m*m, m)
        xs = ys = 0
        for d,c in dc:
            if d == 1:
                for i in range(c):
                    ux.union(xs+i, xs+c*2-1-i)
                xs += c
            else:
                for i in range(c):
                    uy.union(ys+i, ys+c*2-1-i)
                ys += c

        for x,y in xy:
            xc = -ux.table[ux.find(xs+x)]
            yc = -uy.table[uy.find(ys+y)]
            rr.append(xc*yc)

        return True

    while f():
        pass

    return JA(rr, "\n")


print(main())





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

int main(){
    string s,t,u;
    int a,b;
    cin >>s>>t>>a>>b>>u;
    if(!s.compare(u)) cout << a-1<<" "<<b<<endl;
    else cout << a << " " << b-1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int ans[101], i, a=0, j;
	int stnum;
	double weight, hight;
	
	for(i=0;i<=100;++i){
		ans[i] = 0;
	}
	
	while(scanf("%d,%lf,%lf",&stnum, &weight, &hight)!=EOF){
		if(weight/(hight*hight)>=25){
			ans[a] = stnum;
			a++;
		}
	}
	
	for(j = 0; j < a; j++){
		printf("%d\n",ans[j]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
int d[60];

int main() {
    cin >> N;
    rep(i, N) cin >> d[i];

    int sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;

            sum += d[i] * d[j];
        }
    }
    cout << sum / 2 << endl;
}



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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var count = 0;
            while(a.Any(x => x > 0)){
                for(var i = 0; i < n; i++){
                    if(a[i] != 0){
                        count++;
                        while(i < n){
                            if(a[i] == 0){
                                break;
                            }
                            a[i]--;
                            i++;
                        }
                    }
                }

            }

            Console.WriteLine(count);
        }
    }
}


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

int main(){

    string S;
    cin >> S;

    int ans = INT_MAX;
    for(int i = 0; i + 2 < S.length(); i++){
        string num = S.substr(i, 3);
        int diff = abs(753 - stoi(num));
        if(ans > diff) ans = diff;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<array>

using namespace std;

int main() {
	array<int, 32> Q = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;

	int& ans = Q.at(K - 1);
	if (ans < 0) {
		cout << 1 << endl;
	}
	else cout << ans << endl;

	return 0;
}

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

int D[33][33];
ll sum[3][33];
const int INF=INT_MAX/2;

int main(){
  int N,C; cin>>N>>C;
  rep(i,C) rep(j,C) cin>>D[i][j];
  vector<map<int,int> > V(3);
  rep(i,N) rep(j,N){
    int c; cin>>c; c--;
    V[(i+j)%3][c]++;
  }
  rep(i,3) rep(j,C){
    ll tmp=0;
    for(auto m:V[i]) tmp+=1LL*m.second*D[m.first][j];
    sum[i][j]=tmp;
  }
  ll ans=INF;
  rep(i,C) rep(j,C) rep(k,C) if(i!=j&&i!=k&&j!=k){
    ans=min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
template<typename T>
inline void read(T& s)
{
    s=0;int f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){s=s*10+c-'0';c=getchar();}
    s*=f;
}
int n,x;
int s[105];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	int num=0;
	for(int i=0;i<n;i++)
	{
		if(x>=s[i])
		{
			num++;
			x-=s[i];
		}
		else	break;
	}
	if(x!=0 && num==n)	num--;
	cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int data[10][11] = {};

int main ()
{
	int a , b , c;
	char d;
	while( cin >> b >> d >> a >> d >> c )
	{
		if( c == 1 )
		{
			if( a - 1 >= 0 )
			{
				data[a - 1][b]++;
				data[a - 1][b + 1]--;
			}
			data[a][max ( b - 1 , 0 )]++;
			data[a][min ( b + 2 , 10 )]--;
			if( a + 1 < 10 )
			{
				data[a + 1][b]++;
				data[a + 1][b + 1]--;
			}
		} else if( c == 2 )
		{
			if( a - 1 >= 0 )
			{
				data[a - 1][max ( b - 1 , 0 )]++;
				data[a - 1][min ( b + 2 , 10 )]--;
			}
			data[a][max ( b - 1 , 0 )]++;
			data[a][min ( b + 2 , 10 )]--;
			if( a + 1 < 10 )
			{
				data[a + 1][max ( b - 1 , 0 )]++;
				data[a + 1][min ( b + 2 , 10 )]--;
			}
		} else
		{
			if( a - 2 >= 0 )
			{
				data[a - 2][b]++;
				data[a - 2][b + 1]--;
			}
			if( a - 1 >= 0 )
			{
				data[a - 1][max ( b - 1 , 0 )]++;
				data[a - 1][min ( b + 2 , 10 )]--;
			}
			data[a][max ( b - 2 , 0 )]++;
			data[a][min ( b + 3 , 10 )]--;
			if( a + 1 < 10 )
			{
				data[a + 1][max ( b - 1 , 0 )]++;
				data[a + 1][min ( b + 2 , 10 )]--;
			}
			if( a + 2 < 10 )
			{
				data[a + 2][b]++;
				data[a + 2][b + 1]--;
			}
		}
	}
	int ans1 = 0 , ans2 = 0;
	for( size_t i = 0; i < 10; i++ )
	{
		for( size_t j = 1; j < 11; j++ )
		{
			data[i][j] += data[i][j - 1];
		}
	}
	for( size_t i = 0; i < 10; i++ )
	{
		for( size_t j = 0; j < 10; j++ )
		{
			if( data[i][j] == 0 )
			{
				ans1++;
			}
			if( ans2 < data[i][j] )
			{
				ans2 = data[i][j];
			}

		}
	}
	cout << ans1 << endl << ans2 << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, k;
  cin >> n >> k;
  vi p(n);
  rep(i, n) cin >> p[i];

  int s_mx = 0;
  rep(i, k) s_mx += p[i];

  int s = s_mx;
  rep(i, n-k){
    s = s - p[i] + p[i+k];
    // printf("%d %d %d %d\n", i+1, s, p[i], p[i+k]);
    s_mx = max(s, s_mx);
  }

  double ans = ((double) s_mx + k) / 2;
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second
#define bcnt(S) __builtin_popcountll(S)

const int N = 510;
const int M = 1e9 + 7;
const int MN = 2e5 + 1000;
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;

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

char s[MN], ss[MN];
int nex[MN][30], vis[MN];
int num[30];
vector<PII> p;

int main ()
{
	s[0] = '?';
	scanf("%s", s+1);
	memset(nex, INF, sizeof(nex));
	memset(num, 0, sizeof(num));
	memset(vis, 0, sizeof(vis));
	int len = strlen(s);
	for(int i = 1; i < len; i++){
		int t = s[i] - 'a';
		for(int j = num[t]; j < i; j++){
			nex[j][t] = i;
		}
		num[t] = i;
	}
	
//	for(int i = 0; i < 2; i++){
//		for(int j = 0; j < 26; j++)
//			printf("%d ", nex[i][j]);
//		puts("");
//	}
	
	int f = 1, en, n1 = 0;
	queue<PII> q;
	q.push(MP(0, 0));
	while(!q.empty() && f){
		PII u = q.front(); q.pop();
		int t = p.size(); p.push_back(MP(u.y, u.x));
		for(int i = 0; i < 26; i++)
			if(nex[u.x][i] == INF){
			//	printf("%d %c\n", u.y + 1, 'a' + i);
				ss[n1++] = 'a' + i;
				en = t, f = 0; break;
			}else{
				int tt = nex[u.x][i];
				if(!vis[tt]){
					vis[tt] = 1;
					q.push(MP(nex[u.x][i], t));
				}	
			}
	}
	
//	printf("%d %c\n", en, s[en]);
	while(en){
		ss[n1++] = s[p[en].y];
		en = p[en].x;
	}
	
	ss[n1] = '\0';
	reverse(ss, ss+n1);
	printf("%s\n", ss);
	
	return 0;
}

Measured memory_bytes: 28160
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	inc(i, n) { if(s.substr(i, 3) == "ABC") { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int N,M;
  cin >> N;
  vector<string> s(N);
  vector<string> t(M);
  for (int i = 0; i < N; i ++){
    cin >> s.at(i);
  }
  cin >> M;
  for (int i = 0; i < M; i ++){
    cin >> t.at(i);
  }

  int max = 0;
  for (int i = 0; i < N; i ++ ){
    int point = 0;
    string str1;
    str1 = s.at(i);
    for (int j = 0; j < N; j++){
      //cout << s.at(j) <<endl;
      if (str1 == s.at(j) )
        point ++;
      else
        continue;
    }
    
    // cout << "i:" << i << "p:" << point <<endl;
    if (point < max || point == max)
      continue;
    
    
    for(int j = 0; j < M; j++){
      if (str1 == t.at(j) )
        point --;
    }
    if (point > max){
      max = point;
    }
  }
  cout << max << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

int n;
double dp[310][310][310];

double calc(int i, int j, int k){
    if(dp[i][j][k]>=0)return dp[i][j][k];
    if(i+j+k==0)return 0.0;

    double res=0.0;
    if(i)res+=calc(i-1,j,k)*i;
    if(j)res+=calc(i+1,j-1,k)*j;
    if(k)res+=calc(i,j+1,k-1)*k;
    res+=n;
    res*=1.0/(i+j+k);

    return dp[i][j][k]=res;
}

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);  

    cin>>n;
    vector<int> a(4);
    rep(i,n){
        int t; cin>>t;
        a[t]++;
    }

    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(30)<<calc(a[1],a[2],a[3])<<endl;
    return 0;

}

Measured memory_bytes: 465920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n, m;
    while (cin >> n >> m, (n|m)) {
        int ans = INF, ret;
        rep(i, n) {
            if (ans > abs((i+1)*(i+1)+(n-i-1)*(n-i-1)-m*m)) {
                ans = abs((i+1)*(i+1)+(n-i-1)*(n-i-1)-m*m);
                ret = i;
            }
        }
        int i = ret;
        cout << abs(sqrt((i+1)*(i+1)+(n-i-1)*(n-i-1))-m) << endl;
    }
    return 0;
}

Measured memory_bytes: 3300
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
pair<int,bool> Query[200000];
string S;
void Calc(){
	int N = rei();
	int Q = rei();
	S = res();
	for(int i=0;i<Q;i++){
		string S1 = res();
		string S2 = res();
		Query[i] = {S1[0],S2[0] == 'L'}; 
	}
	int LeM = -1;
	int RiM = N;
	for(int i=Q-1;i>=0;i--){
		if(LeM != -1 && S[LeM] == Query[i].first && !Query[i].second){
			LeM--;
		}
		else if(LeM != N-1 && S[LeM+1] == Query[i].first && Query[i].second){
			LeM++;
		}
		if(RiM != 0 && S[RiM-1] == Query[i].first && !Query[i].second){
			RiM--;
		}
		else if(RiM != N && S[RiM] == Query[i].first && Query[i].second){
			RiM++;
		}
	}
	int ans = LeM + 1 + N - RiM;
	ans = min(ans,N);
	ans = N - ans;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 2196
n = int(input())
s = list(input())

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i

        if k >= n:
            continue

        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9204
#include <stdio.h>

int main()
{
	int N,K,h[100000];
	int count = 0;
	scanf("%d %d", &N, &K);
	for (int i = 0; i <= N-1; i++) {
		scanf("%d", &h[i]);
		if (h[i] >= K) {
			count++;
		}
	}
	printf("%d", count);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n,m;
    cin >> n >> m;
    unordered_set<int> div;
    for (int i = 1; i * i <= m; ++i)
    {
        if (m % i == 0){
            div.emplace(i);
            div.emplace(m / i);
        }
    }
    int ans = 1;
    for (auto elem : div)
    {
        int now = m / elem;
        if (now >= n){
            ans = max(ans, elem);
        }
    }
    cout << ans << endl;
}

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

const int INF = 1 << 28;
int dist[100000];

typedef pair<int, int> P;// dist, mod

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	fill((int*)begin(dist), (int*)end(dist), INF);
	int K;
	cin >> K;

	priority_queue<P, vector<P>, greater<P>> q;
	for(int i = 1; i < 10; i++){
		q.push({ i, i % K });
		dist[i % K] = min(dist[i % K], i);
	}

	while(q.size()){
		int m = q.top().second, d = q.top().first;
		//cerr << "m : " << m << ", d : " << d << endl;
		q.pop();
		if(d > dist[m]) continue;
		for(int i = 0; i < 10; i++){
			int nm = (m * 10 + i) % K;
			if(dist[nm] > d + i){
				dist[nm] = d + i;
				q.push({ d + i, nm });
			}
		}
	}

	cout << dist[0] << endl;
}


Measured memory_bytes: 2804
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

long long int N =0;
const int MAXN = 16+10;
int a[MAXN];

int main(){
	scanf("%lld",&N);
	int h=0;
	int cnt=0;
	int flag = 0;
	if(N==10)	flag =1;
	while(N>0){
		h=N%10;
		N=N/10;
		a[cnt]=h;
		cnt++;
	}
	
	for(int i=0;i<cnt-2;i++){
		if(a[i]==9)	flag = 0;
		else	{flag = 1; break;}
	}
	
	//printf("%d\n%d\n",flag,cnt);
	int ans =0;
	if(flag){
		ans=9*(cnt-1)+a[cnt-1]-1;
	}else{
		ans=9*(cnt-1)+a[cnt-1];
	}
	printf("%d\n",ans);
}

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

int main(){
  int n; cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = d[n/2] - d[n/2 -1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c[] = new int[a];;
		for (int i = 0; i < a; i++) {
			c[i] = sc.nextInt();
		}

		int count = 0;
		a -= b;
		count++;
		while (a > 0) {
			a = a - (b - 1);
			count++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 50352
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - y2 + y1
y3 = y2 - x1 + x2
x4 = x1 - y2 + y1
y4 = y1 - x1 + x2
print(x3, y3, x4, y4)


Measured memory_bytes: 9096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
bool prime(int a){
    int sum=0;
    int mid=a/2+2;
    for(int i=2;i<mid;i++){
        if(a%i==0){
            sum++;
            break;
        }
    }
    if(a==2)sum=0;
    return sum==0;
}
int main(){
    int x;cin>>x;
    for(int i=0;i<10000;i++){
        if(prime(i+x)){
            cout<<i+x<<endl;
            break;
        }
    }
    return 0;
}

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

using ll=long long;
using ld=long double;

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cntr=0;
	int ans,c=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			cntr++;
		}
	}
	for(int i=0;i<cntr;i++){
		if(s[i]=='R'){
			c++;
		}
	}
	ans=cntr-c;
	cout<<ans<<'\n';
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


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

typedef long long ll;
const int N = 1000006;
const ll MOD = 1000000007;

int n;
int a[N];
bool np[N];

vector<int> prims;

int lcmm[N];
ll powermod(ll a,ll b){
	ll ret = 1;
	while(b){
		if(b&1){
			ret *= a;
			ret %= MOD;
		}
		b >>= 1;
		a *= a;
		a %= MOD;
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	np[0] = np[1] = true;
	for(int i=4;i<N;i+=2){
		np[i] = true;
	}
	prims.push_back(2);
	for(int i=3;i<N;i+=2){
		if(np[i])continue;
		prims.push_back(i);
		for(ll j=1ll*i*i;j<N;j+=i){
			np[j] = true;
		}
	}

	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int x = a[i];
		for(int j=0;j<(int)prims.size();j++){
			int cnt = 0;
			while(x%prims[j] == 0){
				cnt++;
				x /= prims[j];
			}
			lcmm[prims[j]] = max(lcmm[prims[j]],cnt);
			if(1ll * prims[j] * prims[j] > x)break;
		}
		if(x > 1){
			lcmm[x] = max(lcmm[x],1);
		}
	}
	
	ll LCM = 1;
	for(int i=2;i<N;i++){
		ll t = 1;
		for(int j=0;j<lcmm[i];j++){
			t *= i;
		}
		LCM *= t;
		LCM %= MOD;
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ll t = LCM;
		int x = a[i];
		for(int j=0;j<(int)prims.size();j++){
			int cnt = 0;
			while(x%prims[j] == 0){
				cnt++;
				x /= prims[j];
			}
			t *= powermod(powermod(prims[j],cnt),MOD-2);
			t %= MOD;
			if(1ll * prims[j] * prims[j] > x)break;
		}
		if(x > 1){
			t*= powermod(x,MOD-2);
			t %= MOD;
		}
		ans += t;
		ans %= MOD;
	}
	
	cout<<ans;
	
	return 0;
}


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

using namespace std;

int main() {
	int h[10];
	for (int i = 0; i < 10; ++i) {
		cin >> h[i];
	}

	sort(h, h + 10);

	for (int i = 9; i > 6; --i) {
		cout << h[i] << endl;
	}
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x, k, d, pos=LLONG_MAX, neg=LLONG_MAX;
    cin>>x>>k>>d;
    if(x==0){
        if(k%2) cout<<d;
        else cout<<0;
    }
    else{
        x = abs(x);
        ll m = x%d;
        ll c = (x-m)/d;
        ll mv = max(0ll, k-c);
        x=x-(k-mv)*d;
        k=mv;
        if(k%2==0) pos = x;
        else pos = x-d;
        if(k>0){
            k--;
            if(k%2==0) neg = x-d;
            else neg = x;
        }
        ll ans = min(pos, neg);
        cout<<abs(ans);
    }
}

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

int main(){
  string s,t;
  int ans = 0;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
   if(s.at(i)!=t.at(i)){ans = 1;}
  }
  if(ans == 0){cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
  return 0;
              
 
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int n,i,j,k;
    vector<long long int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);

    }
    sort(v.begin(),v.end());
    cout<<v[n-1]-v[0]<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys

N = 8
row = [-1] * N
col = [0] * N
dpos = [0] * (N*2-1)
dneg = [0] * (N*2-1)


def print_board():
    for i in range(N):
        for j in range(N):
            if row[i] == j:
                print("Q", end='')
            else:
                print(".", end='')
        print("\n", end='')


def put_queen(i):
    if i == N:
        return True
    elif row[i] != -1:
        if put_queen(i+1):
            return True
        else:
            return False
    else:
        for j in range(N):
            if col[j] == 1 or dpos[i+j] == 1 or dneg[i-j+N-1] == 1:
                continue
            row[i] = j
            col[j] = dpos[i+j] = dneg[i-j+N-1] = 1
            if put_queen(i+1):
                return True
            else:
                row[i] = -1
                col[j] = dpos[i+j] = dneg[i-j+N-1] = 0
        return False


line = sys.stdin.readline()
n = int(line)
for i in range(n):
    line = sys.stdin.readline()
    r, c = map(int, line.split())
    row[r] = c
    col[c] = dpos[r+c] = dneg[r-c+N-1] = 1

put_queen(0)
print_board()



Measured memory_bytes: 5624
use proconio::input;

fn main() {
    input! {
        n: usize,
        f: [[usize; 10]; n],
        p: [[isize; 11]; n]
    }

    let mut max = std::isize::MIN;
    for bit in 1..1<<10 {
        let mut counter = vec![0; n];
        for i in 0..10 {
            if (bit >> i) & 1 != 0 {
                for j in 0..n {
                    if f[j][i] == 1 {
                        counter[j] += 1;
                    }
                }
            } 
        }


        let mut sum = 0;
        for i in 0..n {
            sum += p[i][counter[i]];
        }

        if sum > max {
            max = sum;
        }
    }

    println!("{}", max);
}


Measured memory_bytes: 2228
#include<stdio.h>

int main(){
  char  a[1000],b[1000],c[1000],n='\0',tmp='\0';
  int   ca=0,cb=0,cc=0;

  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);

  while(1){
    if(ca == 0){
      n = a[ca++];
    }else{
      if(n == 'a'){
        n = a[ca++];
      }else if(n == 'b'){
        n = b[cb++];
      }
      else if(n == 'c'){
        n = c[cc++];
      }
    }
    if(n != '\0'){
      tmp = n;
    }else{
      break;
    }

  }

  if(tmp == 'a'){
    printf("A");
  }else if(tmp == 'b'){
    printf("B");
  }
  else if(tmp == 'c'){
    printf("C");
  }else{printf("Error");}

  return 0;
}


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

int main() {
	string ans = "AC", S;
	cin >> S;
	bool flg = false;

	if (S[0] != 'A') flg = true;

	int i = S.find('C');
	if (2 <= i and i <= S.size() - 2);
	else flg = true;

	string T = "";
	for (int j = 1; j < i; j++) T += S[j];
	for (int j = i + 1; j < S.size(); j++) T += S[j];

	string U = T;
	transform(T.begin(), T.end(), T.begin(), ::tolower);

	if (U != T) flg = true;

	if (flg) {
		cout << "WA";
	}
	else {
		cout << "AC";
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N;
    int n[100];
    int count=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&n[i]);
    }
    for(int i=0;i<N;i+=2){
        if(n[i]%2==1){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1732
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  string s,t;
  cin>>s>>t;
  int size=s.size();

  bool flag=true;
  for(int i=0;i<size;i++){
    if(s[i]!=t[i]) flag=false; 
  }

  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

bool is_ok(vector<vector<int>> f)
{
  vector<pair<int, int>> qlist;
  rep(i, 8) rep(j, 8) {
    if (f[i][j] == 1) qlist.push_back(make_pair(i, j));
  }
  for (auto v:qlist) {
    int x = v.second;
    int y = v.first;
    for (int i=1; i<8; i++) {
      if (x+i<8)          if (f[y][x+i]==1) return false;
      if (x+i<8&&y+i<8)   if (f[y+i][x+i]==1) return false;
      if (y+i<8)          if (f[y+i][x]==1) return false;
      if (0<=x-i&&y+i<8)  if (f[y+i][x-i]==1) return false;
      if (0<=x-i)         if (f[y][x-i]==1) return false;
      if (0<=x-i&&0<=y-i) if (f[y-i][x-i]==1) return false;
      if (0<=y-i)         if (f[y-i][x]==1) return false;
      if (x+i<8&&0<=y-i)  if (f[y-i][x+i]==1) return false;
    }
  }
  return true;
}

int main()
{
  int k; cin>>k;
  vector<int> r(k, 0);
  vector<int> c(k, 0);
  rep(i, k) {
    cin>>r[i]>>c[i];
  }
  vector<int> a = {0, 1, 2, 3, 4, 5, 6, 7};
  do {
    vector<vector<int>> f(8, vector<int>(8, 0));
    bool flg = true;
    rep(i, k) if (a[r[i]]!=c[i]) flg = false;
    if (!flg) continue;
    rep(i, 8) f[i][a[i]] = 1;
    if (is_ok(f)) {
      rep(y, 8) {
        rep(x, 8) {
          if (f[y][x] == 1) cout << "Q";
          else cout << ".";
        }
        cout << endl;
      }
      return 0;
    }
  } while (next_permutation(a.begin(), a.end()));

  return 0;
}



Measured memory_bytes: 3172
H,W=map(int,input().split())
S= [input().strip() for i in range(H)]
ans=[[0]*W for i in range(H)]
diff=[(-1, -1),(0, -1),(1, -1),
     (-1, 0),           (1, 0),
     (-1, 1),(0, 1),(1, 1),]
for i in range(H):
    for j in range(W):
        if S[i][j]!="#":
            ct=0
            for dh,dw in diff:
                if 0<=i+dh<H and 0<=j+dw<W:
                    ct+=S[i+dh][j+dw]=="#"
            ans[i][j]=str(ct)
        else:
            ans[i][j]="#"
print("\n".join(["".join(x)for x in ans]))

Measured memory_bytes: 3188
s=input()
k=int(input())
ans=''
for c in s:
    t=ord('z')-ord(c)+1
    if t<26 and t<=k:
        k-=t
        ans+='a'
    else:
        ans+=c
if k>0:
    ans=ans[:-1]+chr(ord('a')+(ord(ans[-1])-ord('a')+k)%26)
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 <= 21) cout << "win" << endl;
    else cout << "bust" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	string to = "CF";
	int p = 0;
	for (auto t : s) {
		if (p < (int)to.size() && t == to[p]) {
			p++;
		}
	}	
	if (p == (int)to.size()) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3648