akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <queue>
#include <string>
using namespace std;

vector<int> cm[8];

typedef pair<string, int> P;

map<string ,int> m;

inline void SCM(int i,int v)
{
	cm[i].push_back(v);
	cm[v].push_back(i);
}

void Initcm()
{
	SCM(0,1);
	SCM(1,2);
	SCM(2,3);
	SCM(4,5);
	SCM(5,6);
	SCM(6,7);
	SCM(0,4);
	SCM(1,5);
	SCM(2,6);
	SCM(3,7);
}

void bfs()
{
	queue<P> q;
	q.push(P("01234567",1));//if()でその値があるかどうかSerchしやすくするために+1そのため結果は-1
	while(!q.empty()){
		P p = q.front();q.pop();
		if(m[p.first])
			continue;//値が存在するとき
		m[p.first] = p.second;
		int cnum;
		for(int i=0;i<8;++i){
			if(p.first[i] == '0'){
				cnum = i;
				break;
			}
		}
		for(int i=0;i<cm[cnum].size();++i){
			string str = p.first;
			char c = str[cnum];
			str[cnum] = str[cm[cnum].at(i)];
			str[cm[cnum].at(i)] = c;
			q.push(P(str,p.second+1));
		}
	}
}

int main(void)
{
	Initcm();
	bfs();
		while(1)
		{
			string a;
			string sum;
			for(int i=0;i<8;++i){
				cin >> a;
				sum += a;
			}
			if(cin.eof())
				return 0;
			cout << m[sum] - 1 << endl;
		}
	return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    int X = (double)N / 1.08;
    if(static_cast<int>(X * 1.08) == N) {
        cout << X << endl;
    } else if(static_cast<int>((X + 1) * 1.08) == N) {
        cout << X + 1 << endl;
    } else if(static_cast<int>((X - 1) * 1.08) == N) {
        cout << X - 1 << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
   string a[n];
    int countac=0,countwa=0,counttle=0,countre=0;
    //string s;

    for (int i=0;i<n;i++)
    {
         cin>>a[i];


        if (a[i]=="AC")
         {
             countac++;

         }

         else if (a[i]=="WA")
         {
             countwa++;

         }
           else if (a[i]=="TLE")
         {
             counttle++;

         }
           else if (a[i]=="RE")
         {
             countre++;

         }
    }
 cout<<"AC"<<" x "<<countac<<endl;
  cout<<"WA"<<" x "<<countwa<<endl;

   cout<<"TLE"<<" x "<<counttle<<endl;

    cout<<"RE"<<" x "<<countre<<endl;






}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

typedef unsigned long long ull;

using namespace std;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    X--;
    Y--;

    vector<ull> p(A), q(B), r(C);

    REP(i, A)
        cin >> p[i];

    REP(i, B)
        cin >> q[i];

    REP(i, C)
        cin >> r[i];

    sort(ALL(p), std::greater<>());
    sort(ALL(q), std::greater<>());
    sort(ALL(r), std::greater<>());

    vector<ull> P(A), Q(B), R(C);

    P[0] = p[0];
    Q[0] = q[0];
    R[0] = r[0];

    for (int i = 1; i < A; ++i)
        P[i] = P[i - 1] + p[i];

    for (int i = 1; i < B; ++i)
        Q[i] = Q[i - 1] + q[i];

    for (int i = 1; i < C; ++i)
        R[i] = R[i - 1] + r[i];

    ull current_max = P[X] + Q[Y];

    // cout << "max:" << current_max << " " << P[X] << " " << Q[Y] << endl;

    int x = X, y = Y;

    for (int i = 0; i < C; ++i) {
        ull new_value = current_max + r[i];

        // cout << "new?" << new_value << endl;
        if (x >= 0 && y >= 0) {
            if (p[x] < q[y]) {
                new_value -= p[x];
                x--;
            } else {
                new_value -= q[y];
                y--;
            }
        } else if (x >= 0) {
            new_value -= p[x];
            x--;
        } else if (y >= 0) {
            new_value -= q[y];
            y--;
        } else {
            break;
        }

        current_max = max(current_max, new_value);
    }

    cout << current_max << endl;

    return 0;
}


Measured memory_bytes: 4992
text = input()
count_dict = {}
for ch in text:
  if ch not in count_dict:
    count_dict[ch] = 1
  elif ch in count_dict:
    count_dict[ch] += 1

flag = True
for num in count_dict.values():
  if num % 2 == 0:
    pass
  elif num % 2 == 1:
    flag = False
    
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 2940
# abc135 c city savers
n = int(input())
a_list = list(map(int,input().split())) # 魔物
b_list = list(map(int,input().split())) # 勇者

count = 0
for i in range(n):
    if a_list[i] <= b_list[i]: # i番目の魔物を全部倒せるとき
        #　a_list i+1の数をb_list[i] - a_list[i]分減らす
        yoryoku = b_list[i] - a_list[i]
        if yoryoku < a_list[i+1]: # 余力では次の魔物を全部倒せない時
            count += a_list[i] + yoryoku
            a_list[i+1] -= yoryoku
            a_list[i] = 0
        else: # 余力で次の魔物を全部倒せる時
            count += a_list[i] + a_list[i+1]
            a_list[i + 1] = 0
            a_list[i] = 0
    else:  # 全部倒せないとき
        count += b_list[i]
print(count)

Measured memory_bytes: 82020
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	int s = (a + b + c) / 2;
	float area = sqrt(s * (s - a) * (s - b) * (s - c));
	cout << area << '\n';
	return 0;
}



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

int main() {
	int N;

	while(cin >> N, N) {
		vector<int> scores;
		int score;
		for(int i=0; i < N; i++) {
			cin >> score;
			scores.push_back(score);
		}

		sort(scores.begin(), scores.end());
		int sums = 0;
		for(int i=1; i<scores.size()-1; i++) {
			sums+=scores[i];
		}
		int ans = sums/(scores.size()-2);
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
import sys


def main():
    N = int(input())
    S = input()

    count = 0
    for i in range(2, N):
        if S[i-2] != "A":
            continue
        if S[i-1] != "B":
            continue
        if S[i] != "C":
            continue
        count += 1

    print(count)


if __name__ == '__main__':
    main()


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

struct Card { char suit, value; };

void print(Card cards[], int n) {
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << cards[i].suit << cards[i].value;
  }
  cout << endl;
}

bool is_stable (Card a[], Card b[], int n) {
  for (int i = 0; i < n; i++)
    if (a[i].suit != b[i].suit) return false;

  return true;
}

void bubble_sort(Card cards[], int n) {
  for (int i = 0; i < n; i++)
    for (int j = n - 1; 1 <= j; j--)
      if (cards[j].value < cards[j - 1].value)
        swap(cards[j], cards[j - 1]);
};

void selection_sort(Card cards[], int n) {
  for (int i = 0; i < n; i++) {
    int minj = i;

    for (int j = i; j < n; j++)
      if (cards[j].value < cards[minj].value)
        minj = j;

    if (i != minj)
      swap(cards[i], cards[minj]);
  }
}

int main() {
  int n;
  cin >> n;

  Card cards_a[n] = {0};
  Card cards_b[n] = {0};

  for (int i = 0; i < n; i++) {
    char suit, value;
    cin >> suit >> value;

    cards_a[i].suit = suit;
    cards_a[i].value = value;
 
    cards_b[i].suit = suit;
    cards_b[i].value = value;
  }

  bubble_sort(cards_a, n);
  print(cards_a, n);
  cout << "Stable" << endl;

  selection_sort(cards_b, n);
  print(cards_b, n);
  cout << (is_stable(cards_a, cards_b, n) ? "Stable" : "Not stable") << endl;

  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll D,c[30],s[400][30];
vec t(400);
ll score(vec A){
    ll ans=0,last[30]={0};
    rep1(i,D){
        ans+=s[i][A[i]];
        last[A[i]]=i;
        rep1(j,26) ans-=c[j]*(i-last[j]);
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>D;
    rep1(i,26) cin>>c[i];
    rep1(i,D)rep1(j,26) cin>>s[i][j];
    rep1(i,D) cin>>t[i];
    int M;
    cin>>M;
    rep(i,M){
        int d,q;
        cin>>d>>q;
        t[d]=q;
        cout<<score(t)<<"\n";
    }
}

Measured memory_bytes: 3676
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def main():
    n = int(input())
    tree = [[] for _ in range(n)]
    for i in range(n - 1):
        a, b = map(int, input().split())
        tree[a - 1].append([b, i])
        tree[b - 1].append([a, i])

    def dfs(v, p, p_col):
        col = 1
        for u, idx in tree[v - 1]:
            if u == p:
                continue
            if col == p_col:
                col += 1
            res[idx] = col
            col += 1
            dfs(u, v, res[idx])

    res = [0 for _ in range(n - 1)]
    dfs(1, -1, -1)
    print(max(res))
    print("\n".join(map(str, res)))


if __name__ == '__main__':
    main()


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

using namespace std;
using LL = long long;

const int maxn = 100100;
int n, m;
int h[maxn], in[maxn];
vector<int> G[maxn];

signed main() {
  // freopen("in", "r", stdin);
  int u, v;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
    G[i].clear();
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    in[u]++;
    in[v]++;
    if (h[u] > h[v]) G[u].emplace_back(v);
    if (h[v] > h[u]) G[v].emplace_back(u);
  }
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (G[i].size() == in[i]) ret++;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 8760
# 重み付きUnionFind
#############################################################
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        # 根への距離を管理
        self.weight = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
#############################################################

# 大小関係が複数与えられるような問題では、重み付きUnionFindが使えることが多い

N, M = map(int, input().split())
wuf = WeightedUnionFind(N)

for _ in range(M):
    l, r, d = map(int, input().split())
    if wuf.same(l, r):
        # lからrへの重みがdか否か
        if wuf.diff(l, r) != d:
            print("No")
            exit()
    else:
        # lからrへの重みはdであるとする
        wuf.union(l, r, d)

print("Yes")


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

using namespace std;

int main(void)
{
  int a,b;
  int flag=0;
  string s;

  cin>>a>>b;
  cin>>s;

  for(int i=0;i<a;i++)
  {
    if(s[i]== '-')
    {
      flag=1;
    }
  }
  
  for(int i=a+1;i<a+b+1;i++)
  {
    if(s[i]== '-')
    {
      flag=1;
    }
  }

  if(flag==0 && s[a]=='-')
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }  
}


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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  string s = to_string(n);
  bool ok = true;
  for (int i = 0; i < s.length() / 2; i++) 
    if (s[i] != s[s.length() - i - 1])
      ok = false;
  cout << (ok ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back

void solve(){
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b));
    
} 

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





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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////////
map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res[i] += 1;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}
/////////////////////////////////////////////////////////////

ll n;

map<ll, ll> cnt_base;
map<ll, ll> cnt;
map<ll, ll> cnt_acc;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  for (ll i = 1LL; i <= n; ++i) {
    for (auto &e: prime_factorization(i)) {
      cnt_base[e.first] += e.second;
    }
  }

  for (auto &e : cnt_base) {
    cnt[e.second] += 1LL;
  }

  ll whole = 0;

  for (auto &e : cnt) {
    whole += e.second;
  }

  for (auto &e : cnt) {
    cnt_acc[e.first] = whole;
    whole -= e.second;
  }

  ans = 0LL;

  ll p_74 = 0LL;
  auto ptr = cnt_acc.lower_bound(74);
  if (ptr != cnt_acc.end()) {
    p_74 = ptr->second;
  }

  ll p_2 = 0LL;
  ptr = cnt_acc.lower_bound(2);
  if (ptr != cnt_acc.end()) {
    p_2 = ptr->second;
  }
  ll p_24 = 0LL;
  ptr = cnt_acc.lower_bound(24);
  if (ptr != cnt_acc.end()) {
    p_24 = ptr->second;
  }

  ll p_4 = 0LL;
  ptr = cnt_acc.lower_bound(4);
  if (ptr != cnt_acc.end()) {
    p_4 = ptr->second;
  }
  ll p_14 = 0LL;
  ptr = cnt_acc.lower_bound(14);
  if (ptr != cnt_acc.end()) {
    p_14 = ptr->second;
  }

  ans += p_74;

  ans += p_24 * max(p_2 - 1LL, 0LL);

  ans += p_14 * max(p_4 - 1LL, 0LL);

  ans += p_4 * max(p_4 - 1LL, 0LL) * max(p_2 - 2LL, 0LL) / 2LL;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
int n;
int t, x, y;
int main()
{
	scanf("%d",&n);
	int flag = 0;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d %d %d",&t, &x, &y);
		if(x + y > t)
		{
			flag = 1;
			continue;
		}
		else 
		{
			if(t % 2 == 0 && (x + y) % 2 != 0)
			{
				flag = 1;
				continue;
			}
			else if(t % 2 != 0 && (x + y) % 2 == 0)
			{
				flag = 1;
				continue;
			}
		}
	}
	if(flag == 0) printf("Yes\n");
	else printf("No\n");
	}



Measured memory_bytes: 256
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        string S = ReadLine();
        string ans = "";
        foreach(char s in S)
        {
            int convert = (int)s + N;
            if(convert > 90)
            {
                convert -= 26;
            }
            ans += (char)convert;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 34772
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    string S1,S2; cin >> S1 >> S2;
    ll ans = 1;
    rep(i,N){
        if(i == 0){
            if(S1[i] == S1[i+1]){
                ans *= 6;
                ans %= MOD;
                i++;
            }
            else{
                ans *= 3;
                ans %= MOD;
            }
        }
        else{
            if(S1[i] == S1[i+1]){
                if(S1[i-1] == S2[i-1]){
                    ans *= 2;
                    ans %= MOD;
                }
                else{
                    ans *= 3;
                    ans %= MOD;
                }
                i++;
            }
            else{
                if(S1[i-1] == S2[i-1]){
                    ans *= 2;
                    ans %= MOD;
                }
            }
        }
    }
    cout << ans << endl;

}
    



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll v,e,r;cin>>v>>e>>r;
  vector<vp> g(v);vll dis(v,MOD);
  rep(i,0,e){
    ll s,t,d;cin>>s>>t>>d;
    g[s].push_back(make_pair(t,d));
  }
  priority_queue<P,vector<P>,greater<P> > pq;
  dis[r]=0;
  pq.push(make_pair(dis[r],r));
  while(!pq.empty()){
    P p=pq.top();
    pq.pop();
    ll from=p.second;
    if(dis[from]<p.first)continue;
    for(auto &edge:g[from]){
      if(dis[edge.first]>dis[from]+edge.second){
        dis[edge.first]=dis[from]+edge.second;
        pq.push(make_pair(dis[edge.first],edge.first));
      }
    }
  }
  rep(i,0,v){
    if(dis[i]!=MOD){ out(dis[i]);}
    else{out("INF");}
  }
}




Measured memory_bytes: 19332
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<bool> > data;
  data.resize(h);
  for (int i = 0; i < h; ++i) { data[i].resize(w); }

  // white: true, black: false
  int white_num = 0;
  for (int i = 0; i < h; ++i)
  {
    string str;
    cin >> str;
    for (int j = 0; j < w; ++j)
    {
      data[i][j] = (str[j] == '.' ? true : false);
      if (data[i][j]) { ++white_num; }
    }
  }

  vector<vector<int> > score;
  score.resize(h);
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j) { score[i].push_back(0); }
  }

  vector<pair<int, int> > visit;
  visit.push_back(make_pair(0, 0));
  score[0][0] = 1;
  while (!visit.empty())
  {
    const pair<int, int>& curr = visit.back();
    int i = curr.first;
    int j = curr.second;
    visit.pop_back();

    const int di[4] = { -1, 0,  0, 1 };
    const int dj[4] = { 0, 1, -1, 0 };

    for (int n = 0; n < 4; ++n)
    {
      int ni = i + di[n];
      int nj = j + dj[n];

      if (ni >= 0 && ni < h && nj >= 0 && nj < w && data[ni][nj] && (score[ni][nj] == 0 || score[i][j] + 1 < score[ni][nj]))
      {
        score[ni][nj] = score[i][j] + 1;
        visit.push_back(make_pair(ni, nj));
      }
    }
  }

  cout << (score[h - 1][w - 1] == 0 ? -1 : white_num - score[h - 1][w - 1]) << endl;

  return 0;
}


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

namespace ABC_C
{
    class C056
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            int sum = 0;
            int i = 0;
            while (true)
            {
                i++;
                sum += i;
                if (sum >= X) break;
            }

            Console.WriteLine(i);
        }

    }
}


Measured memory_bytes: 11092
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    scanf("%d %d", &a, &b);
    int ans = max(a + b, max(a - b, a * b));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);		
		int K = sc.nextInt();		
		int A[] = {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};

		System.out.println(A[K-1]);
	}
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int n;
int a, b, c;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int i;
    for(i = 0; i < n; ++i){
        int v;
        cin >> v;
        v %= 4;
        if(v == 0){
            ++a;
        }
        else if(v == 2){
            ++b;
        }
        else{
            ++c;
        }
    }
    if(a >= c || (b == 0 && a >= c - 1)){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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 N;
  cin >> N;
  vector<int> D(N);
  rep(i, N) cin >> D[i];
  sort(D.begin(), D.end());
  multiset<int> st{0};
  bool flag = true;
  rep(i, N) {
    if (flag)
      st.insert(D[i]);
    else
      st.insert((24-D[i])%24);
    flag ^= 1;
  }
  int ans = 1e9;
  for (auto i = st.begin(); i != st.end(); i++) {
    for (auto j = i; j != st.end(); j++) {
      if (i == j)
        continue;
      chmin(ans, min(*j-*i, 24+*i-*j));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int A,B;cin >> A >> B;
    cout<<max({A+B, A-B, A*B})<<std::endl;
}


Measured memory_bytes: 256
class Unionfind():
  def __init__(self, n=10**6):
    self.n=n
    self.root=[-1]*(n+1)
    self.rnk=[0]*(n+1)
  def find(self, x):
    if(self.root[x]<0):
      return x
    else:
      self.root[x]=self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x=self.find(x)
    y=self.find(y)
    if(x==y):return
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x]+=self.root[y]
      self.root[y]=x
    else:
      self.root[y]+=self.root[x]
      self.root[x]=y
      if(self.rnk[x]==self.rnk[y]):
        self.rnk[y]+=1
  def same(self, x, y):
    return self.find(x)==self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
uf=Unionfind()
n,m=map(int,input().split())
for _ in range(m):
  a,b=map(int,input().split())
  uf.unite(a,b)
print(max([uf.count(i+1) for i in range(n)]))

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

using namespace std;


int main() {
  int n;
    cin>>n;
    string s1,s2,s;
    cin>>s1>>s2;
    for(int i=0;i<n;i++){
        s+=s1[i];
        s+=s2[i];
    }
    //s+='\0';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

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

const int MAXN = 1e5 + 667;

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

    string s;
    cin >> s;
    int cnt = s.size();
    for(int i = 0;i<cnt;i++){
        cout << "x";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    static boolean solve(int N){
        for(int a=1; a<10; a++) for(int b=1; b<10; b++){
            if(a*b==N){
                return true;
            }
        }
        return false;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(solve(N) ? "Yes" : "No");
    }
}


Measured memory_bytes: 25172
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double map[100][3];
double map_size;
double center[3];
double prev_max;
double down_rate;

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

double update(double error_limit)
{
	double max = -1;
	double temp_1;
	int max_index;
	for (int i = 0; i < map_size; i++)
	{
		temp_1 = 0;
		temp_1 += pow(map[i][0] - center[0], 2);
		temp_1 += pow(map[i][1] - center[1], 2);
		temp_1 += pow(map[i][2] - center[2], 2);
		if (temp_1 > max)
		{
			max = temp_1;
			max_index = i;
		}
	}
	max = sqrt(max);
	if (down_rate < error_limit)
		return max;
	else
	{
		double vector[3];
		vector[0] = map[max_index][0] - center[0];
		vector[1] = map[max_index][1] - center[1];
		vector[2] = map[max_index][2] - center[2];
		center[0] += vector[0] * down_rate;
		center[1] += vector[1] * down_rate;
		center[2] += vector[2] * down_rate;
		prev_max = max;
		down_rate *= 0.99;
		return -1;
	}
}

int main()
{
	int count;
	double x, y, z;
	while (scanf("%d", &count) && count != 0)
	{
		center[0] = 0;
		center[1] = 0;
		center[2] = 0;
		fors(i, count)
		{
			scanf("%lf %lf %lf", &x, &y, &z);
			map[i][0] = x;
			map[i][1] = y;
			map[i][2] = z;
			center[0] += x;
			center[1] += y;
			center[2] += z;
		}
		map_size = count;
		center[0] /= map_size;
		center[1] /= map_size;
		center[2] /= map_size;
		prev_max = 10;
		down_rate = 1;
		while (update(1e-10) < 0)
			;
		printf("%.5f\n", update(1e-10));
	}
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int dp[3005][3005];
pair<int,int> r[3005][3005];

int main(){
  string S, T;
  cin >> S >> T;

  REP(i,1,S.size()+1){
    REP(j,1,T.size()+1){
      if(dp[i][j] < dp[i-1][j]){
        dp[i][j] = dp[i-1][j];
        r[i][j] = make_pair(i-1,j);
      }
      if(dp[i][j] < dp[i][j-1]){
        dp[i][j] = dp[i][j-1];
        r[i][j] = make_pair(i,j-1);
      }
      if(S[i-1] == T[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
        r[i][j] = make_pair(i-1,j-1);
      }
    }
  }

  string ret;
  int x = S.size(), y = T.size();
  int cnt = dp[S.size()][T.size()];
  while(cnt>0){
    pair<int,int> nxt = r[x][y];
    if(cnt != dp[nxt.first][nxt.second]){
      ret += S[x-1];
    }
    x = nxt.first;
    y = nxt.second;
    cnt = dp[x][y];
  }
  reverse(ALLOF(ret));
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 105984
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
ll c;
//ll visit[100001]={0};
//vector<ll> adj[1000001];
void dfs(ll v,ll visit[],vector<ll> adj[]){
    if(visit[v]) return;
    visit[v]=1;
    c++;
    for(ll i=0;i<adj[v].size();i++){
        if(visit[adj[v][i]]==0){
            dfs(adj[v][i],visit,adj);
        }
    }
}
    
int main(){
   IOS;
int t;t=1;//cin>>t;
while(t--){
ll n,m1;
cin>>n>>m1;
vector<ll> adj[n];ll ans=1;
map<pair<ll,ll>,ll> m;
for(ll i=0;i<m1;i++){
    ll x,y;cin>>x>>y;
    if(m[{x-1,y-1}]==0){
    adj[x-1].pb(y-1);
    adj[y-1].pb(x-1);
        m[{x-1,y-1}]=1;
        m[{x-1,y-1}]=1;
    }
    
}
ll visit[n]={0};

for(ll i=0;i<n;i++){
 
    if(visit[i]==0){c=0;
        dfs(i,visit,adj);
        ans=max(ans,c);
    }
}
cout<<ans;

}
    
    

    
    





return 0;}


Measured memory_bytes: 37980
#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)
using namespace std;
typedef long long ll;
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))

const ll INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

ll w[MAX_N], v[MAX_N];
ll dp[MAX_N][MAX_V];

int main() {
  int n, W;
  cin >> n >> W;
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,MAX_N) rep(j,MAX_V) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n) {
    for(int sum_v = 0; sum_v <= MAX_V; ++sum_v){
      if(sum_v - v[i] >= 0){
        mins(dp[i+1][sum_v], dp[i][sum_v-v[i]]+w[i]);
      }
      mins(dp[i+1][sum_v], dp[i][sum_v]);
    }
  }
  ll res = (ll)0;
  rep(sum_v, MAX_V){
    if(dp[n][sum_v] <= W) res = sum_v;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int a[10003]={0};
  cin>>N;
  int sum=0;
  for(int i=1;i<=N;i++)
  {
    cin>>a[i];
  }
  for(int i=1;i<=N;i++){
    for(int k=1;k<=10000;k++){
      if(a[i]%2==0){
        a[i]=a[i]/2;
        sum++;
      }else{
        break;
      }
    }
  }
  cout<<sum<<endl;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  
  for(int i=0;i<N;i++) {
    cin >> S;
     if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(S != "Y" && i<N-2){
      continue;
    }
    else if(S != "Y" && i==N-1) {
      cout << "Three" << endl; 
   }
  }
 }

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;

    map < string , vpii > h ;
    for ( int i=1 ; i < n + 1 ; i++ )
    {
        string s ; cin >> s ;
        int p ; cin >> p ;

        h[s].pb ( mp ( p , i ) ) ;
    }

    for ( auto i : h )
        sort ( allrev ( h[i.F] ) ) ;

    for ( auto i : h )
    {
        for ( auto j : i.S )
            cout << j.S , line
    }
}

int main()
{fast
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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


int dp[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll lc = lcm(c, d);

  ll fir = b/c - (a-1)/c;
  ll sec = b/d - (a-1)/d;
  ll thi = b/lc - (a-1)/lc;

  ll ans = (b-a+1) - (fir + sec - thi);
  cout << ans << endl;
}

/*





















*/


Measured memory_bytes: 256
#coding: utf-8

cards = [[0 for i in range(13)] for j in range(4)]
suits = {'S':0, 'H':1, 'C':2, 'D':3, 0:'S', 1:'H', 2:'C', 3:'D'}
n = int(input())
for i in range(n):
    a, b = map(str, input().split())
    c = int(b) - 1
    cards[suits[a]][c] = 1
for i in range(4):
    for j in range(13):
        if cards[i][j] == 0:
            print(suits[i], j + 1)


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n, q;
  cin >> n >> q;
  vector< stack<int> > a(n);

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int t, x; cin >> t >> x;
      a[t].push(x);
    } else if (command == 1) {
      int t; cin >> t;
      if (!a[t].empty()) ans.push_back(a[t].top());
    } else {
      int t; cin >> t;
      if (!a[t].empty()) a[t].pop();
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 4292
#include <stdio.h>
int main(){
	int a[100],b[100],i=0,j;
	char op[100];

	while(1){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op[i]=='?')
			break;
		i++;
	}
	for(j=0;j<i;j++){
		if(op[j]=='+')
			printf("%d",a[j]+b[j]);
		else if(op[j]=='-')
			printf("%d",a[j]-b[j]);
		else if(op[j]=='*')
			printf("%d",a[j]*b[j]);
		else if(op[j]=='/')
			printf("%d",a[j]/b[j]);
		printf("\n");
	}	
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<queue>
using namespace std;
priority_queue<int> qe;
int n,m;
long long x;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x;
		qe.push(x);
	}
	long long sum=0;
	for(int i=0;i<m;i++){
		if(!qe.empty()){
			int t=qe.top();
		t/=2;
		qe.pop();
		qe.push(t);
		}
	}
	while(!qe.empty()){
		sum+=qe.top();
		qe.pop();
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <climits>      // to use INT_MIN and INT_MAX
using namespace std;
typedef long long ll;

ll arr[100005];

ll gcd(ll a, ll b) {    // Euclidean algorithm
	if (b == 0) return a;
      return gcd(b, (a%b));
      // doing a%b will also help swap both numbers in the case b>a
}

bool multiples(ll N, ll K, ll min, ll max) {
      ll gcdRes = 0;
      
      // (1) CHECK FOR GCD IN ARRAY
      for(ll i=0; i<N; i++) {
            gcdRes = gcd(gcdRes, arr[i]);
      }

      // (2) CHECK IF TARGET K IS DIVISIBLE BY GCD
      bool flag = false;
      if(K % gcdRes != 0) {
            flag = true;
      }
      return flag;
}

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

      ll N, K, min = INT_MAX, max = INT_MIN;
      cin >> N >> K;

      for(int i=0; i<N; i++) {
            cin >> arr[i];
            
            if(arr[i] == K) { // box already contains target K
                  cout << "POSSIBLE" << endl;
                  exit(0);
            }
            if(arr[i] < min) min = arr[i];
            if(arr[i] > max) max = arr[i];
	}
      // If max (eg. 5) is less than target (eg. 10), 
      // Even if min=1 (smallest possible from constraints), abs diff will never reach target:
      if(max < K) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
      }
      if(multiples(N , K, min, max) == true){
		cout << "IMPOSSIBLE" << endl;
	}
	else cout << "POSSIBLE" << endl; 
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

ll a, b, c, x, y;
ll best = 1E18;

int main(){
  cin >> a >> b >> c >> x >> y;

  for(ll take = 0;take <= max(x, y);++take){
    ll lx = max(0LL, x - take);
    ll ly = max(0LL, y - take);
    relaxMin(best, lx * a + ly * b + 2 * take * c);
  }

  cout << best << '\n';

  return 0;
}


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

int main() {
    int n ;
    std::vector< long long > a ;
    std::cin >> n ;
    
    for( int i = 0 ; i < n ; i++ ) {
        long long ii ;
        std::cin >> ii ;
        a.push_back( ii ) ;
    }
    std::cout << *std::min_element( a.begin() , a.end() ) << " " << *std::max_element( a.begin() , a.end() ) << " " << std::accumulate( a.begin() , a.end() , 0LL ) << std::endl ;
}



Measured memory_bytes: 3288
# coding: utf-8
# Your code here!

N=int(input())
l=list(map(int,input().split()))

high=l[0]
for i in range(N-1):
    if l[i+1]-l[i]<(-1):
        print("No")
        exit()
    high=max(high,l[i+1])
    if l[i+1]<(high-1):
        print("No")
        exit()
        
print("Yes")


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll v = 0;
    for (int i = (int)sqrt(n); i >= 1; i--) {
        if (n % i == 0) {
            v += i + n/i;
            break;
        }
    }
    cout << v - 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
  int n; cin>>n;
  ll ans = 0;
  reps(i,n){
    // cerr << i-1 SP ans << endl;
    ostringstream oss;
    oss << i;
    string s = oss.str();
    int m = s.size();
    if(s[0]==s[m-1]){
      ans++;
    }

    int f = s[0]-'0';
    int l = s[m-1]-'0';
    if(l==0) continue;

    if(l*10+f>i) continue;
    else ans+=2;

    if(l*100+f>i) continue;
    else ans += min(((i-l*100-f)/10+1),10)*2;

    if(l*1000+f>i) continue;
    else ans += min(((i-l*1000-f)/10+1),100)*2;

    if(l*10000+f>i) continue;
    else ans += min(((i-l*10000-f)/10+1),1000)*2;

    if(l*100000+f>i) continue;
    else ans += min(((i-l*100000-f)/10+1),10000)*2;

  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
def c_4adjacent(N, A):  # 解説通りに実装
    # 4の倍数、4の倍数でない2の倍数、奇数の数
    num_4, num_2, num_other = 0, 0, 0
    for a in A:
        if a % 4 == 0:
            num_4 += 1
        elif a % 2 == 0:
            num_2 += 1
        else:
            num_other += 1

    if num_2 == 0:
        ans = 'Yes' if num_other <= num_4 + 1 else 'No'
    else:
        ans = 'Yes' if num_other <= num_4 else 'No'
    return ans

N = int(input())
A = [int(i) for i in input().split()] 
print(c_4adjacent(N, A))


Measured memory_bytes: 14252
using System;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int n, k;
        n = int.Parse(str[0]);
        k = int.Parse(str[1]);
        long ans = k;
        if (n > 1)
            for (int i = 0; i < n - 1; i++)
                ans *= k - 1;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
N=int(input())
height_list=list(map(int,input().split()))
score_list=[ 0, abs(height_list[0]-height_list[1]) ]



for i in range(2,N):

    tmp=min(
        abs(height_list[i]-height_list[i-1])+score_list[i-1],
        abs(height_list[i]-height_list[i-2])+score_list[i-2]
    )

    score_list.append(tmp)

print(score_list[N-1])



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

int n, dat[10000000];

void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    for (int i = 0; i < n * 2 - 1; i++) dat[i] = (1LL << 31) - 1;
}

void updata(int k, long long v) {
    k += n - 1;
    dat[k] = v;
    while(k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

long long query(int a, int b, int k = 0, int l = 0, int r = n) {
    if (r <= a || b <= l) return (1LL << 31) - 1;

    if (a <= l && r <= b) return dat[k];

    long long vl = query(a, b, 2 * k + 1, l, (l + r) / 2),
              vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
}

int main() {
    int q;
    cin >> n >> q;
    init(n);
    while(q--) {
        long long a, b, c;
        cin >> a >> b >> c;
        if (a) {
            cout << query(b, c + 1) << endl;
        }
        else {
            updata(b, c);
        }
    }
    return 0;
}


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

typedef pair<int, int> P;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	priority_queue<P> que;
	int n = M;
	for( int i = 0; i < N; i++ ) {
		que.push( make_pair( A[i] - A[i] / 2, i ) );
	}
	while( n > 0 ) {
		int i, num;
		tie( num, i ) = que.top();
		que.pop();
		A[i] /= 2;
		n--;
		que.push( make_pair( A[i] - A[i] / 2, i ) );
	}

	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans += A[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 1784