akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  multiset<int> a;
  rep (i, n) {
    int x;
    cin >> x;
    a.insert(x);
  }
  rep (i, m) {
    int maxi = *a.rbegin();
    a.erase(--a.end());
    a.insert(maxi / 2);
  }
  lint sum = 0;
  allrep (A, a) sum += A;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4992
package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	g := make([][]int, n)

	for i := 0; i < n-1; i++ {
		a := scanInt()-1
		b := scanInt()-1

		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	pa := make([]int,0)
	pb := make([]int,0)
	done := make([]bool, n)
	q := queue{node{0,0}}
	done[0] = true
	pa = append(pa,0)
	for q.Len() != 0 {
		next := q.Pop()
		for _, e := range g[next.num] {
			if done[e] {
				continue
			}

			if (next.c+1)%2 == 0 {
				pa = append(pa,e)
			} else {
				pb = append(pb,e)
			}
			q.Push(node{e,(next.c+1)%2})
			done[e] = true
		}
	}

	p := make([]int, n)

	if len(pa) <= n/3 {
		c0 := 3
		for _, e := range pa {
			p[e] = c0
			c0+=3
		}

		c1 := 1
		for i := 0; i < n; i++ {
			if p[i] != 0 {
				continue
			}

			p[i] = c1
			c1++
			if c1%3==0 && c1<c0 {
				c1++
			}
		}
	} else if len(pb)<=n/3 {
		c0 := 3
		for _, e := range pb {
			p[e] = c0
			c0+=3
		}

		c1 := 1
		for i := 0; i < n; i++ {
			if p[i] != 0 {
				continue
			}

			p[i] = c1
			c1++
			if c1%3==0 && c1<c0 {
				c1++
			}
		}
	} else {
		c0 := 1
		for _, e := range pa {
			p[e] = c0
			c0+=3
			if c0 > n {
				break
			}
		}
		c0 = 2
		for _, e := range pb {
			p[e] = c0
			c0+=3
			if c0>n {
				break
			}
		}
		c0 = 3
		for i := 0; i < n; i++ {
			if p[i] != 0 {
				continue
			}

			p[i] = c0
			c0+=3
		}
	}

	ans := make([]interface{}, n)
	for i := 0; i < n; i++ {
		ans[i] = p[i]
	}

	fmt.Fprintln(wr, ans...)

}

type node struct {
	num, c int
}

type queue []node

func (q queue) Len() int { return len(q) }
func (q *queue) Push(a node) { *q = append(*q, a) }
func (q *queue) Pop() node {
	res := (*q)[0]; *q = (*q)[1:]; return res
}


Measured memory_bytes: 31360
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define deb(x) cout<<#x<<" "<<x<<el;
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

template<typename T>
void read(T& a)
{
  cin>>a;
}
template<typename T, typename... Args>
void read(T& a,Args&... args)
{
  cin>>a; read(args...);
}

template<typename T>
void write(T a)
{
  cout<<a<<' ';
}
template<typename T, typename... Args>
void write(T a,Args... args)
{
  cout<<a<<' '; write(args...);
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=((ans*((n-i)%N))%N*modInverse(i+1,N))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    cin>>n>>m;
    if(m>=n)
    {
      cout<<"unsafe";
    }
    else cout<<"safe";
  }


  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    int ord = 0;
    deque<char>ans;
    int n = (int)s.size();
    rep(i,n) ans.push_back(s[i]);
    rep(i,q) {
        int t;
        cin >> t;
        if(t==1) {
            ord ^= 1;
        }
        if(t==2) {
            int f;
            cin >> f;
            f--;
            char c;
            cin >>c;
            if((ord^f) ==0) {
                ans.push_front(c);
            }
            else {
                ans.push_back(c);
            }
        }

    }
    if(ord==1) {
        while(!ans.empty()) {
            char c = ans.back();
            ans.pop_back();
            cout << c;
        }
    } else {
        while(!ans.empty()) {
            char c = ans.front();
            ans.pop_front();
            cout << c;
        }
    }
    cout << endl;
}
    

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x3 - dx;
  int y4 = y3 - dy;
  cout << x3 SP y3 SP x4 SP y4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int ac = 0, wa = 0, tle = 0, re = 0;
	int N;
	std::cin >> N;
	std::string str;
	for (auto _ : boost::irange(N))
	{
		std::cin >> str;
		if (str == "AC")
		{
			++ac;
		}
		else if (str == "WA")
		{
			++wa;
		}
		else if (str == "TLE")
		{
			++tle;
		}
		else
		{
			++re;
		}
	}
	std::cout << "AC x " << ac << std::endl;
	std::cout << "WA x " << wa << std::endl;
	std::cout << "TLE x " << tle << std::endl;
	std::cout << "RE x " << re << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,m,x,y,p,q;
	cin>>n;
	vector<double>P(n);
	for(int i=0;i<n;i++) cin>>P[i];
	vector<vector<double>>dp(n,vector<double>(n+1)); 
	//dp[i][j] means probability of having j heads till ith index;
	dp[0][0]=1-P[0];
	dp[0][1]=P[0];
	for(int i=1;i<n;i++){
		dp[i][0]=(1-P[i])*dp[i-1][0];
		
		for(int j=1;j<=(i+1);j++){
			dp[i][j]=P[i]*dp[i-1][j-1]+(1-P[i])*(dp[i-1][j]);
			
		}
		
	}
	double ans=0;
	for(int j=n/2+1;j<=n;j++) ans+=dp[n-1][j];
	cout<<setprecision(15)<<ans<<"\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	
	solve();

}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            List < string> row1 = Console.ReadLine().Split(' ').ToList();
            List < string> row2 = Console.ReadLine().Split(' ').ToList();
            List < string> row3 = Console.ReadLine().Split(' ').ToList();

            
            List<List<string>> orgData = new List<List<string>>();
            orgData.Add(row1);
            orgData.Add(row2);
            orgData.Add(row3);

            int cnt = int.Parse(Console.ReadLine());
            List<int> dataList = new List<int>();
            for (int loop = 0; loop < cnt; loop++) {
                dataList.Add(int.Parse(Console.ReadLine()));
            }

            List < List<bool>> bingo = new List<List<bool>>();
            for (int loop = 0; loop < 3; loop++)
            {
                bingo.Add(new List<bool>() { false, false, false });
            }

            for (int loop = 0; loop < 3; loop++) {
                for (int loop2 = 0; loop2 < 3; loop2++)
                {
                    bingo[loop][loop2] = dataList.Contains(int.Parse(orgData[loop][loop2]));
                }     
            }

            bool ans = false;

            //縦
            for (int loop = 0; loop < 3; loop++)
            {
                int trueCount = 0;
                for (int loop2 = 0; loop2 < 3; loop2++)
                {
                    if (bingo[loop][loop2]) {
                        trueCount++;
                    }
                }
                if (trueCount == 3) {
                    ans = true;
                    break;
                }
            }
            if (ans)
            {
                Console.WriteLine("Yes");
            Console.ReadLine();
                return;
            }
            //横
            for (int loop = 0; loop < 3; loop++)
            {
                int trueCount = 0;
                for (int loop2 = 0; loop2 < 3; loop2++)
                {
                    if (bingo[loop2][loop])
                    {
                        trueCount++;
                    }
                }
                if (trueCount == 3)
                {
                    ans = true;
                    break;
                }
            }
            if (ans)
            {
                Console.WriteLine("Yes");
            Console.ReadLine();
                return;
            }

            //斜め
            ans = bingo[0][0] && bingo[1][1] && bingo[2][2];
            if (ans)
            {
                Console.WriteLine("Yes");
            Console.ReadLine();
                return;
            }

            ans = bingo[2][0] && bingo[1][1] && bingo[0][2];
            if (ans)
            {
                Console.WriteLine("Yes");
            Console.ReadLine();
                return;
            }

            Console.WriteLine("No");
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
typedef long long ll;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(all(a));

    while (true)
    {
        int pre = a[0];
        rep(i, n)
        {
            if (a[i + 1] % a[0] == 0)
            {
                a[i + 1] = a[0];
            }
            else
            {
                a[i + 1] = a[i + 1] % a[0];
            }
        }
        sort(all(a));
        if (a[0] == pre)
            break;
    }

    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stack>
using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){
    for(int v = nt[u]; v<n; v++){
        nt[u] = v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i=0; i<n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;
    
    while(!S.empty()){
        int u = S.top();
        int v = next(u);
        if(v!=-1){
            if(color[v]==WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;
    for(int u=0; u<n; u++){
        if(color[u]==WHITE){
            dfs_visit(u);
        }
    }
    for(int i=0; i<n; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    int u,k,v;
    
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }
    
    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}

Measured memory_bytes: 3100
import re
from sys import stdin
N=(stdin.readline().rstrip())
for i in range(7):
    mae="keyence"[0:i+1]
    ato="keyence"[i+1:8]
    if re.search(".*keyencekeyence",N):
        if (re.sub('.*keyencekeyence', '', N)=="")==True:
            print("YES")
            break
    if re.search("keyencekeyence.*",N):
        if (re.sub('keyencekeyence.*', '', N)=="")==True:
            print("YES")
            break
    if (re.sub('.*keyence', '', N)=="")==True:
        print("YES")
        break
    if (re.sub('keyence.*', '', N)=="")==True:
        print("YES")
        break
    if re.match("%s.*%s"%(mae, ato),N):
        if (re.sub('%s.*%s'%(mae,ato) ,"", N)=="")==True:
            print("YES")
            break
if i==6:
    print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    char c;
    cin >> c;
    if(65 <= c && c <= 90) cout << "A";
    else cout << "a";
}

Measured memory_bytes: 3620
// =================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// =================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=2000+10;

struct Edge { int v,nxt; } e[N];
int head[N];

inline void addEdge(int u,int v) {
    static int cnt=0;
    e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
}

int n;
int a[N],vis[N],deg[N];
int G[N][N];

inline void dfs(int u) {
    vis[u]=1;
    for (re int i=1;i<=n;++i) {
        if (vis[i]||!G[u][i]) continue;
        ++deg[i],addEdge(u,i);
        dfs(i);
    }
}

inline void topsort() {
    priority_queue<int> Q;
    for (re int i=1;i<=n;++i)
        if (!deg[i]) Q.push(i);
    while (!Q.empty()) {
        int u=Q.top(); Q.pop();
        printf("%d ",a[u]);
        for (re int i=head[u];i;i=e[i].nxt) Q.push(e[i].v);
    }
}

int main() {
    n=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1);
    for (re int i=1;i<=n;++i)
        for (re int j=i+1;j<=n;++j) {
            if (__gcd(a[i],a[j])==1) continue;
            G[i][j]=G[j][i]=1;
        }
    for (re int i=1;i<=n;++i)
        if (!vis[i]) dfs(i);
    topsort();
    return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>
#define na 2000000 //int main()の中でA[2000000]2百万個を用意できないので外に出す

void CountingSort(int*, int*, int);
int B[na];
int main(){

  int n, A[na], C[10000], i, k;

  scanf("%d", &n);
  for(i=0; i<10000; i++){
    C[i]=0;}
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    C[ A[i] ]++; //配列A[i]=0とするとC[0]の中身を+1する
  }

  //累積和を入れたC'を作る
  for(i=1; i<10000; i++){//以降はC'しか使わないのでC[]に代入して使う
    C[i]=C[i]+C[i-1];
  }//C[0]はC[0]のままなので飛す
  
  CountingSort(A, C, n);

  for(i=1; i<=n-1; i++) printf("%d ", B[i]);
  printf("%d\n", B[n]);

  return 0;
}

void CountingSort(int A[], int C[], int n){

  int i;
  
  for(i=0; i<=n; i++){
    B[ C[ A[n-i] ] ] = A[n-i];
    C[ A[n-i] ]--;

  }

}





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

int main() {
  int n;
  cin >> n;
  if (n >= 64) {
    cout << "64" << endl;
  }
  else if (n >= 32) {
    cout << "32" << endl;
  }
  else if (n >= 16) {
    cout << "16" << endl;
  }
  else if (n >= 8) {
    cout << "8" << endl;
  }
  else if (n >= 4) {
    cout << "4" << endl;
  }
  else if (n >= 2) {
    cout << "2" << endl;
  }
  else {
    cout << "1" << endl;
  }
    
  
   


}


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

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

  vector<int64_t> r_cum(N, 0), g_cum(N, 0), b_cum(N, 0);
  for (int64_t i = 0; i < N; i++) {
    if (S[i] == 'R') {
      r_cum[i] = 1;
    } else if (S[i] == 'G') {
      g_cum[i] = 1;
    } else if (S[i] == 'B') {
      b_cum[i] = 1;
    }
  }

  for (int64_t i = 1; i < N; i++) {
    r_cum[i] += r_cum[i - 1];
    g_cum[i] += g_cum[i - 1];
    b_cum[i] += b_cum[i - 1];
  }

  int64_t sum = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = i + 1; j < N; j++) {
      if (S[i] == S[j]) {
	continue;
      }

      vector<int64_t> *cum;
      char nokori;
      if (S[i] == 'R' && S[j] == 'G' || S[i] == 'G' && S[j] == 'R') {
	nokori = 'B';
	cum = &b_cum;
      } else if (S[i] == 'R' && S[j] == 'B' || S[i] == 'B' && S[j] == 'R') {
	nokori = 'G';
	cum = &g_cum;
      } else if (S[i] == 'G' && S[j] == 'B' || S[i] == 'B' && S[j] == 'G') {
	nokori = 'R';
	cum = &r_cum;
      }
      sum += (*cum)[N - 1] - (*cum)[j];

      if (j + j - i < N && S[j + j - i] == nokori) {
	sum--;
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> X){
    vector<long long> Y = X;
    sort(X.begin(), X.end());
    for (auto&& y : Y) {
        if (y < X[N/2]) {
            std::cout << X[N/2] << std::endl;
        } else {
            std::cout << X[N/2-1] << std::endl;
        }
    }
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> X(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&X[i]);
    }
    solve(N, X);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2;
typedef pair<int, P2> P3; typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact; constexpr Prime<10> prime;
constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int main(){
	ll n, x; cin >> n >> x;
	
	cout << 3 * (n - gcd(n, x)) << endl;
	return 0;
}


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

int n,k;
int a[100005];
int dp[100005];

int solve(int x)
{
    if(dp[x]!=-1)
        return dp[x];
    int &ans=dp[x];
    ans=1;
    for(int i=0;i<n;i++)
        if(x-a[i]>=0)
            ans=min(ans,solve(x-a[i]));
    ans^=1;
    return ans;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    cin>>n>>k;
    //cout<<n<<" "<<k<<"\n";
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    int ans=0;
    ans=solve(k);
    cout<<(ans?"First":"Second");    
}


Measured memory_bytes: 9020
l, r = gets.chomp.split(" ").map(&:to_i)

min = 10 ** 6
for i in l..(r - 1)
    for j in (i + 1)..r
        min = (i * j) % 2019 if min > (i * j) % 2019
        break if min == 0
    end
    break if min == 0
end
puts min


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

struct UnionFind{
    int num;
    vector<int> par,rank;
    UnionFind(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        return (par[x]==x?x:par[x]=root(par[x]));
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return rank[root(x)];}
    int count(){return num;}
};

const int N=1001;

int V,d;
int F[N];

void fibonacchi(){
    F[0]=2,F[1]=3;
    for (int i=2;i<N;++i) F[i]=(F[i-1]+F[i-2])%N;
}

void solve(){
    UnionFind uf(V);
    for (int i=0;i<V;++i){
        for (int j=i+1;j<V;++j){
            if (abs(F[i]-F[j])<d){
                uf.merge(i,j);
            }
        }
    }
    cout << uf.count() << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    fibonacchi();
    while(cin >> V >> d){
        solve();
    }
}


Measured memory_bytes: 3072
while True:
  n = int(input())
  if n == 0:break
  to = []
  for i in range(n):
    line = list(map(int, input().split()))
    for j in range(n):
      x, y = line[2 * j:2 * j + 2]
      to.append(y * n + x)
  
  order = []
  used = [False] * (n * n)
  def dfs(x):
    if used[x]:return
    used[x] = True
    dfs(to[x])
    order.append(x)
  
  for i in range(n * n):
    dfs(i)
  order.reverse()
  
  def dfs2(x, used, group):
    if x in group:return True
    if used[x]:return False
    group.add(x)
    used[x] = True
    return dfs2(to[x], used, group)
  
  used = [False] * (n * n)
  ans = 0
  for i in order:
    group = set()
    if not used[i]:
      if dfs2(i, used, group):ans += 1
  print(ans)
  


Measured memory_bytes: 6672
n,w_max = gets.split.map(&:to_i)
weight,value = gets.split.map(&:to_i)

dp=[0] * w_max
for i in 0..weight-1
  dp[i]=0
end
for i in weight..w_max
  dp[i]=value
end

for i in 1...n
  pre_dp = dp.clone
  weight,value = gets.split.map(&:to_i)
  for j in weight..w_max
    dp[j] = pre_dp[j-weight] + value
    dp[j] = pre_dp[j] if dp[j]<pre_dp[j]
  end
end
puts dp.last


Measured memory_bytes: 67836
s = input()
a, b = int(s[:2]), int(s[2:])

ma = 1 <= a <= 12
mb = 1 <= b <= 12

if ma and mb:
  print("AMBIGUOUS")
elif ma:
  print("MMYY")
elif mb:
  print("YYMM")
else:
  print("NA")


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

int main () {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++) {
        cout << S.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
function Main(input){
  input = input.split(" ");
  var a = parseInt(input[0],10);
  var b = parseInt(input[1],10);
  var c = parseInt(input[2],10);
  a = parseInt(input[1],10);
  b = parseInt(input[0],10);
  a = parseInt(input[2],10);
  c = parseInt(input[1],10);
  console.log('%d',a,b,c);

}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 7372
/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}

fn main() {
    let s = read_input();
    let mut ws = s.split_whitespace();
    let in_n: i32 = ws.next().unwrap().parse().unwrap();
    let mut txy: Vec<(i32, i32, i32)> = (0..in_n)
        .map(|_| {
            let t: i32 = ws.next().unwrap().parse().unwrap();
            let x: i32 = ws.next().unwrap().parse().unwrap();
            let y: i32 = ws.next().unwrap().parse().unwrap();
            (t, x, y)
        })
        .collect();
    txy.insert(0, (0, 0, 0));

    let mut ok = true;
    for window in txy.windows(2) {
        let ((t1, x1, y1), (t2, x2, y2)) = (window[0], window[1]);
        let dt = t2 - t1;
        let d = (x1 - x2).abs() + (y1 - y2).abs();
        ok &= dt >= d && (dt - d) % 2 == 0
    }
    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 10492
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

if(n<1200){
    cout << "ABC" << endl;
}
else if(n<2800){
    cout << "ARC" << endl;
}
else cout << "AGC" << endl;







return 0;}
///....


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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	int max = a + b;
	if(max < (a - b))
	{
		max = a - b;
	}
	if(max < (a * b))
	{
		max = a * b;
	}
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);


    string n;
    cin >> n;
    for(char x: n){
        if(x == '7'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";






    return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int A[N];
  int B[N];
  int C[N-1];
  int i;
  for(i=0;i<N;i++){
   cin >> A[i];
    A[i]--;
  }
  for(i=0;i<N;i++){
   cin >> B[i]; 
  }
  for(i=0;i<N-1;i++){
   cin >> C[i]; 
  }
  
  int conf=0;
  for(i=0;i<N;i++){
   conf += B[A[i]];
    if(i<N-1 && A[i]+1 == A[i+1]){
     conf += C[A[i]]; 
    }
  }
  
  cout << conf << endl;
  
  
  
  
return 0;
} 

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll mod = 1000000007;
    vector<ll> sums(n - 1);
    sums[0] = a[0] % mod;
    rep(i, n - 2)
    {
        sums[i + 1] = (sums[i] + a[i + 1]) % mod;
    }
    ll result = 0;

    rep(i, n - 1)
    {
        result = (result + sums[i] * a[i + 1]) % mod;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 6044
#include <iostream>

int gcd(int readVal1, int readVal2){
    if(0 == readVal1 % readVal2){
        return readVal2;
    }else{
        return gcd(readVal2, readVal1 % readVal2);
    }
}

int main(){
    int x, y;
    std::cin >> x >> y;

    std::cout << gcd(x, y) << std::endl;

    return 0;
}


Measured memory_bytes: 3112
class UnionFind:
    """素集合を木構造として管理する"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """要素xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を統合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """要素xを含む集合の要素数を求める"""
        return -self.parent[self.root(x)]


n, k, l = map(int, input().split())
info_k = [list(map(int, input().split())) for i in range(k)]
info_l = [list(map(int, input().split())) for i in range(l)]

ufk = UnionFind(n)
ufl = UnionFind(n)
uf_total = UnionFind(n)

for a, b in info_k:
    a -= 1
    b -= 1
    ufk.merge(a, b)

for a, b in info_l:
    a -= 1
    b -= 1
    ufl.merge(a, b)

pair_cnt = {}
for i in range(n):
    if (ufk.root(i), ufl.root(i)) not in pair_cnt:
        pair_cnt[ufk.root(i), ufl.root(i)] = 1
    else:
        pair_cnt[ufk.root(i), ufl.root(i)] += 1

ans = [pair_cnt[ufk.root(i), ufl.root(i)] for i in range(n)]
print(*ans)

Measured memory_bytes: 137472
/*********************************************
* 20.05.19 AtCoder Beginner Contest 153
* 
* 
*********************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define et "\n"

class CRun{
private:
    struct {
    }gv;
public:
    char problem_num;
    
    CRun(){
        problem_num = 'C';
    }; 
    ~CRun(){};
    void build();
    void solve_A(); void solve_B(); void solve_C(); 
    void solve_D(); void solve_E(); void solve_F();
};

void CRun::build(){
    
}

/*********************************************
A - Serval vs Monster
敵の体力H
味方の攻撃1回で体力をA減らせる
勝つための攻撃回数は？
*********************************************/
void CRun::solve_A(){
    int H; cin >> H;
    int A; cin >> A;
    
    int ans = 0;
    //ans += (H % A > 0 ? H / A + 1 : H / A);
    ans += (H - 1) / A + 1;
    cout << ans;
}

/*********************************************
B - Common Raccoon vs Monster
モンスターの体力H
N種類の攻撃で敵のHPをAN減らせる
同じ攻撃を使わずに敵を倒せるか？
*********************************************/
void CRun::solve_B(){
    
    int H; cin >> H;
    int N; cin >> N;
    int A[N]; rez(i,N) cin >> A[i];
    
    int sum = 0;
    for (auto &ix : A) sum += ix;
    
    string ans[] = {"Yes", "No"};
    if (sum >= H) {
        cout << ans[0];
    }
    else {
        cout << ans[1];
    }
    
}

/*********************************************
C - Fennec vs Monster
N개체의 적, H_N 만큼의 체력
공격 : 적을 1개체 골라서 체력을 1만큼 줄임
필살 : 적을 1개체 골라서 체력을 0으로 만듦
K회만큼 필살기를 쓸 수 있을 때, 승리하는 공격의 최소횟수는?
*********************************************/
void CRun::solve_C(){
    int enemy_num; cin >> enemy_num;
    int ultimate_cnt; cin >> ultimate_cnt;
    int enemy_hp[enemy_num]; rez(i,enemy_num) cin >> enemy_hp[i];
    
    ll ans = 0;
    sort(enemy_hp, enemy_hp + enemy_num, greater<int>());
    for (int ix = ultimate_cnt; ix < enemy_num; ix++) {
        ans += enemy_hp[ix];
    }
    cout << ans;
}

/*********************************************

*********************************************/
void CRun::solve_D(){
    
}

/*********************************************

*********************************************/
void CRun::solve_E(){
    
}

/*********************************************

*********************************************/
void CRun::solve_F(){
    
}

int main(){
    CRun run;
    run.build();
    switch (run.problem_num) {
        case 'A' : run.solve_A();
        case 'B' : run.solve_B();
        case 'C' : run.solve_C();
        case 'D' : run.solve_E();
        case 'E' : run.solve_D();
        case 'F' : run.solve_F();
    }
}



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

int main() {

	int n, m; cin >> n >> m;
	
	vector<pair<int, int>> id;
	vector<vector<pair<int, int>>> prefecture(n);
	for (int i = 0; i < m; i++) {
		int p, y; cin >> p >> y;
		id.push_back({ --p, --y });
		prefecture[p].push_back({ y,i });
	}
	for (int i = 0; i < prefecture.size(); i++) {
		sort(prefecture[i].begin(), prefecture[i].end());
		for (int j = 0; j < prefecture[i].size(); j++) {
			id[prefecture[i][j].second].second = j;
		}
	}
	for (int i = 0; i < m; i++) {
		cout << setw(6) << setfill('0') << id[i].first + 1 << setw(6) << setfill('0') << id[i].second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=2e5+10;
struct node{
	LL b,l,r;
}a[M];
LL X,n;
bool cmp(node A,node B){
	return A.b*A.l+(X-A.b)*A.r>B.b*B.l+(X-B.b)*B.r;
}
LL calc(node A,LL invest){
	return invest>=A.b ? (invest-A.b)*A.r : (invest-A.b)*A.l;
}
bool check(LL k){
	LL cnt=k/X;
	LL profit=0;
	LL loss=0,ans=-1;
	for (int i=1;i<=cnt;i++) profit+=(X-a[i].b)*a[i].r;
	for (int i=cnt+1;i<=n;i++) loss+=a[i].b*a[i].l;
	for (int i=cnt+1;i<=n;i++){
		ans=max(ans,profit-loss+a[i].b*a[i].l+calc(a[i],k%X));
	}
	profit+=(X-a[cnt+1].b)*a[cnt+1].r; loss-=a[cnt+1].b*a[cnt+1].l;
	for (int i=1;i<=cnt;i++) ans=max(ans,profit-(X-a[i].b)*a[i].r-loss+calc(a[i],k%X));

	return ans>=0;
}
int main(){
	n=read(); X=read();
	F(i,1,n) a[i]=(node){read(),read(),read()};
	sort(a+1,a+n+1,cmp);
	LL l=0,r=n*X,ans=n*X;
	while (l<=r){
		LL mid=(l+r>>1);
		if (check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 4480
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int c = 0;
        if (s.charAt(0) == '1') c++;
        if (s.charAt(1) == '1') c++;
        if (s.charAt(2) == '1') c++;
        System.out.println(c);
	}
}

Measured memory_bytes: 35628
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
	int n,m;
	bool isvalid(int x,int y)
	{
		if(x>=0&&x<n&&y>=0&&y<m)
		{
			return true;
		}
		return false;
	}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
int i=0,j=n-1;
int cnt=0;
while(i<j)
{
	if(s[i]=='W')
	{
		if(s[j]=='R')
		{
			char temp=s[j];
			s[i]=s[j];
			s[j]=temp;
			cnt++;
			i++;
			j--;
		}
		else
		{
			j--;
		}
	}
	else
	{
		i++;
	}
}
cout<<cnt<<endl;
}



Measured memory_bytes: 3748
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

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

using namespace std;

const LL MOD=1e9+7;

int n,m,x,y,s,t,dist[100010][3];
vector <int> g[100010];
queue <pair <pii,int> > q;

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
	}
	cin>>s>>t;
	rep(i,100005) rep(j,3) dist[i][j]=1e9;
	dist[s][0]=0;
	q.push({{s,0},0});
	while(!q.empty())
	{
		pair <pii,int> t=q.front();
		q.pop();
		rep(i,g[t.fi.fi].size())
		{
			if(dist[g[t.fi.fi][i]][(t.se+1)%3]==1e9)
			{
				dist[g[t.fi.fi][i]][(t.se+1)%3]=t.fi.se+1;
				q.push({{g[t.fi.fi][i],t.fi.se+1},(t.se+1)%3});
				//cout<<t.fi.fi<<' '<<t.se<<' '<<t.fi.se<<endl;
				//cout<<g[t.fi.fi][i]<<' '<<(t.fi.se+1)%3<<' '<<t.se+1<<endl<<endl;
			}
		}
	}
	if(dist[t][0]==1e9) puts("-1");
	else cout<<dist[t][0]/3<<endl;
	rt0;
}

Measured memory_bytes: 6912
N = int(input())
para = [[c for c in input()] for i in range(N)]
b = []
dict = {}
ans = 0
for i in range(N):
    para[i].sort()
    b.append("".join(para[i]))
    if b[i] not in dict:
        dict[b[i]] = 1
    else :
        ans += dict[b[i]]
        dict[b[i]] += 1 

print(ans)



Measured memory_bytes: 39704
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		long N = Long.parseLong(in.readLine());

		long a = 1, b = N;
		for (long i = 2; i < Math.sqrt((double) N) + 1; ++i) {
			if (N % i == 0) {
				if ((a + b) > (i + N / i)) {
					a = i;
					b = N / i;
				}
			}
		}
		long result = a + b - 2;
		System.out.println(result);
	}
}


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

const int N_MAX=100, M_MAX=100;
char p[N_MAX+1][M_MAX+1];

int main(){
	string n;
	cin >> n;
	if((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3])) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}




Measured memory_bytes: 256
n = int(input())
march = [0, 0, 0, 0, 0]

for i in range(n):
    name = input()
    if name[0] == "M":
        march[0] += 1
    elif name[0] == "A":
        march[1] += 1
    elif name[0] == "R":
        march[2] += 1
    elif name[0] == "C":
        march[3] += 1
    elif name[0] == "H":
        march[4] += 1

ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += march[i] * march[j] * march[k]
print(ans)

Measured memory_bytes: 3064