akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
    int H ,W;
    cin>>H>>W;
    while(H > 0){
        for(int i =0;i<H;i++){
            for(int j = 0;j<W;j++){
                if((i+j)%2 == 0){
                    cout <<"#";
                    if(j == W-1){
                        cout<<""<<endl;
                    }
                }else{
                   cout <<".";
                    if(j == W-1){
                        cout<<""<<endl;
                    } 
                }
            }
            if(i == H-1){
                cout<<""<<endl;
            }
        }
        cin>>H>>W; 
        
    }
    return 0;
}


Measured memory_bytes: 3080
// ConsoleApplication8.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

	sort(a.begin(), a.end());


	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int sum = a[i] + a[j];
			int tmp_j = j+ 1;
			while (tmp_j < n && a[tmp_j] < sum)
			{
				cnt++;
				tmp_j++;
			}
		}

	}
	cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)
 
ll n;
vector<ll> x;
vector<ll> y;
map<ll,vector<ll>> xx;
map<ll,vector<ll>> yy;
map<ll,ll> yetx;
map<ll,ll> yety;
vector<bool> b;
 
ll calc( ll curi, ll curx, ll cury, ll&xn, ll&yn )
{
	ll sum = 1;
	b[curi] = true;
	if( yetx[curx] == 0 )
	{
		++yn;
		yetx[curx] = 1;
		for( auto& i : xx[curx] ) if( !b[i] )
		{
			sum += calc( i, x[i], y[i], xn, yn );
		}
	}
	if( yety[cury] == 0 )
	{
		++xn;
		yety[cury] = 1;
		for( auto& i : yy[cury] ) if( !b[i] )
		{
			sum += calc( i, x[i], y[i], xn, yn );
		}
	}
	return sum;
}
 
int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	cin>>n;
	x.assign( n, 0 );
	y.assign( n, 0 );
	b.assign( n, false );
	REP(i,n)
	{
		cin>>x[i]>>y[i];
		xx[x[i]].push_back( i );
		yy[y[i]].push_back( i );
	}
 
	ll sum = 0;
	REP( i, n ) if( !b[i] )
	{
		yetx.clear();
		yety.clear();
		ll xn = 0, yn = 0;
		ll c = calc( i, x[i], y[i], xn, yn );
		//cout << i << ":" <<  xn << " " << yn << " " << c << endl;
		sum += xn * yn - c;
	}
 
 
	cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 29824
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<string> s(N); 
	vector<int> t(N);
	rep(i, 0, N)cin >> s[i] >> t[i];
	string X; cin >> X;

	int last;
	rep(i, 0, N) {
		if (s[i] == X) {
			last = i;
			break;
		}
	}

	int ans = 0;
	rep(i, last + 1, N)ans += t[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
string s;
int res;
int32_t main() {
    DAU
    cin >> s;
    for (const char& c : s)
        res = (res + c - '0') % 9;
    if (!res)
        cout << "Yes";
    else cout << "No";
    PLEC
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

    int min_cost = 100000000;
    sort(a.begin(), a.end());
    int min_a = a[0];
    int max_a = a[N-1];

    for(int i = min_a; i <= max_a; i++) {
        int cost = 0;
        for(int j=0; j<N; j++) {
            cost += pow(a[j]-i, 2);
        }
        min_cost = min(min_cost, cost);
    }
    cout << min_cost << endl;
}

Measured memory_bytes: 3600
K,X=map(int,input().split())
MaxValue=1000000

if X-K<-1*MaxValue:
  ans=-1*MaxValue
  while ans<X+K:
    print(ans)
    ans+=1

elif X+K>MaxValue:
  ans=X-K+1
  while ans<=MaxValue:
    print(ans)
    ans+=1
else:
  for i in range(X-K+1,X+K):
    print(i)

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

string alpha_l = "qwertasdfgzxcvvb";

bool l_check(char c) {
	for (char a : alpha_l) {
		if (c == a) return true;
	}
	return false;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while (1) {
		string s;
		cin >> s;
		if (s == "#") break;
		int ans = 0;
		bool flag = l_check(s[0]);
		REP (i, 1, s.size()) {
			if (flag != l_check(s[i])) {
				flag = !flag;
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;

const int MN = 100100;

int lc = 0;
int l[MN], r[MN], p[MN], sz[MN];

int readtree(const string &s, int &c) {
    assert(s[c] == '(');
    c++;
    if (s[c] == ')') {
        c++;
        return -1;
    }
    int n = lc++;
    l[n] = readtree(s, c);
    r[n] = readtree(s, c);
    assert(s[c] == ')');
    c++;
    sz[n] = 1;
    if (l[n] != -1) {
        p[l[n]] = n;
        sz[n] += sz[l[n]];
    }
    if (r[n] != -1) {
        p[r[n]] = n;
        sz[n] += sz[r[n]];
    }
    return n;
}

int used[MN];
int uc = 0;

bool mark(int x, int y) {
    if (x == -1 || used[x] == uc) {
        if (y == -1) return true;
        return false;
    }
    if (y == -1) return false;
    used[x] = uc;
    return mark(l[x], l[y]) && mark(r[x], r[y]);
}

int dp[MN];
bool useddp[MN];

int solve(int n) {
    if (useddp[n]) return dp[n];
    useddp[n] = true;
    queue<int> q;
    vector<int> v;
    q.push(n);
    while (!q.empty()) {
        int m = q.front(); q.pop();
        v.push_back(m);
        if (l[m] != -1) {
            q.push(l[m]);
        }
        if (r[m] != -1) {
            q.push(r[m]);
        }
    }
    reverse(v.begin(), v.end());
    int ma = sz[n]-1;
    int S = sz[n];
    int m = v[0];
    int u = 0;
    while (n != m) {
        if (sz[n] % sz[m] == 0) {
            uc++;
            bool f = true;
            int fc = 0;
            for (int d: v) {
                if (used[d] != uc) {
                    int e = d;
                    for (int i = 0; i < u; i++) {
                        e = p[e];
                    }
                    if (!mark(e, m)) {
                        f = false;
                        break;
                    }
                    fc++;
                }
            }
            if (fc == sz[n] / sz[m] && f) {
                ma = min(ma, sz[n] / sz[m] - 1 + solve(m));
            }
        }
        u++;
        m = p[m];
    }
    return dp[n] = ma;
}

int main() {
    string s;
    cin >> s;
    int c = 0;
    p[0] = -1;
    readtree(s, c);
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 10772
n, m = [int(x) for x in input().split()]
locs = [int(x) for x in input().split()]

locs.sort()
 
difLocs = []
first = locs[0]
for bot,top in zip(locs, locs[1:]):
  if top == first:
    break
  difLocs.append(top-bot)
 
difLocs.sort()
if (m-n) < 0:
  print(0)
else:
  newLocs = difLocs[0:m-n]
  print(sum(newLocs))

Measured memory_bytes: 13832
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1;
    bool up = false, down = false, equal = false;
    rep(i,n-1){
        if(a[i+1] > a[i]){
            if(down){ans++;down = false;}
            else up = true;
        }
        if(a[i+1] == a[i])equal = true;
        if(a[i+1] < a[i]){
            if(up){ans++;up = false;}
            else down = true;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

bool IsAdvance(const auto p1, const auto p2, const int t) {
    int len = abs(p1.first - p2.first) + abs(p1.second - p2.second);
    if ((len % 2) != (t % 2)) return false;
    if (t < len) return false;
    return true;
}

bool Solve() {
    pair<int, int> cur(0, 0);
    int n, cur_t = 0;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        pair<int, int> nxt;
        int t;
        cin >> t >> nxt.first >> nxt.second;
        if (!IsAdvance(cur, nxt, t - cur_t)) return false;

        cur_t = t;
        cur = nxt;
    }

    return true;
}

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

    if (Solve()) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    n = int(inputs[0])
    LIMIT = 100000
    sixs = [6]
    nines = [9]
    while sixs[-1] <= LIMIT:
        sixs.append(6 * sixs[-1])
    sixs.pop()
    while nines[-1] <= LIMIT:
        nines.append(9 * nines[-1])
    nines.pop()

    choises = [1]
    choises.extend(sixs)
    choises.extend(nines)

    # [count]
    dp = [0]

    for i in range(1, n+1):
        candidates = []
        for c in choises:
            if i - c >= 0:
                candidates.append(dp[i-c] + 1)
        dp.append(min(candidates))

    return dp[-1]


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 4508
#include<iostream>

using namespace std;

int main()
{
    int n;
    int x=1;
    cin >> n;
    while(x<=n){
        if(x%3==0||x%10==3||(x/10)%10==3||(x/100)%10==3||(x/1000)%10==3)
            cout << " " << x ;
        x++;
    }
    cout << endl;
    return 0;
}



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

using namespace std;

int main(){

    int n;
    vector<char> v;

    cin >> n;

    for(int i = 0; i < n; i++){
        char s;
        cin >> s;
        v.emplace_back(s);
    }

    auto x = find(v.begin(), v.end(), 'Y');

    if(x == v.end()){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, ans;
int d[60], sum[60];
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &d[i]);
		sum[i] = sum[i - 1] + d[i];
	}
	for(int i = 1; i <= n; i ++) {
		ans += (sum[n] - sum[i]) * d[i];
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    int x = min(n, 4095);
    vector<int> vs(n), ws(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &vs[i], &ws[i]);
    }
    vector<vector<pair<int, int>>> a(x);
    vector<int> vv(20), ww(20);
    for (int i = 0; i < x; ++i) {
        int cur = 0;
        for (int j = i; ; j = (j-1)/2) {
            vv[cur] = vs[j], ww[cur++] = ws[j];
            if(!j) break;
        }
        a[i].resize(1 << cur, {0, 0});
        for (int k = 0; k < (1 << cur); ++k) {
            for (int j = 0; j < cur; ++j) {
                if(k & (1 << j)){
                    a[i][k].first += ww[j];
                    a[i][k].second += vv[j];
                }
            }
        }
        sort(a[i].begin(),a[i].end());
        for (int j = 0; j+1 < a[i].size(); ++j) {
            a[i][j+1].second = max(a[i][j+1].second, a[i][j].second);
        }
    }
    int q;
    cin >> q;
    vector<pair<int, int>> b(1 << 10);
    while(q--){
        int v, l;
        cin >> v >> l;
        v--;
        if(v < x){
            printf("%d\n", (--lower_bound(a[v].begin(),a[v].end(), make_pair(l+1, 0)))->second);
        }else {
            int ans = 0;
            int cur = 0;
            int y = v;
            for (; y >= x; y = (y-1)/2) {
                vv[cur] = vs[y], ww[cur++] = ws[y];
            }
            for (int k = 0; k < (1 << cur); ++k) {
                b[k].first = 0;
                b[k].second = 0;
                for (int j = 0; j < cur; ++j) {
                    if(k & (1 << j)){
                        b[k].first += ww[j];
                        b[k].second += vv[j];
                    }
                }
            }
            sort(b.begin(), b.begin()+(1 << cur));
            int len = a[y].size()-1;
            for (int k = 0; k < (1 << cur); ++k) {
                if(b[k].first > l) break;
                while(b[k].first+a[y][len].first > l) len--;
                ans = max(ans, b[k].second+a[y][len].second);
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}

Measured memory_bytes: 93104
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int m,f,b;
    cin >> m >>f >>b;
    if(b<=m){
        cout << 0 << endl;
    }
    else if(m+f<b){
        puts("NA");
    }
    else{
        cout << b-m<< endl;
    }
    return 0;
}



Measured memory_bytes: 3100
Module Module1

    Sub Main()
        Dim readline As String = ""
        Dim hogehoge() As String

        readline = Console.ReadLine()

        hogehoge = readline.Split(" ")

        If kawaiso(hogehoge) Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If

        Console.ReadKey()

    End Sub


    Private Function kawaiso(ByVal hogehoge As String()) As Boolean

        If hogehoge.Length = 3 Then
            Dim flg As Boolean = True

            If (hogehoge(0) <> hogehoge(1)) AndAlso (hogehoge(1) <> hogehoge(2)) AndAlso (hogehoge(2) <> hogehoge(0)) Then
                Return False
            End If

            If ((hogehoge(0) = hogehoge(1)) AndAlso hogehoge(2) <> hogehoge(0)) OrElse
               ((hogehoge(1) = hogehoge(2)) AndAlso hogehoge(0) <> hogehoge(1)) OrElse
               ((hogehoge(2) = hogehoge(0)) AndAlso hogehoge(1) <> hogehoge(2)) _
                Then
                Return True
            End If
        End If


        Return False
    End Function

End Module


Measured memory_bytes: 20432
n, m, x, y = gets.chomp.split.map(&:to_i)
xarr = gets.chomp.split.map(&:to_i)
yarr = gets.chomp.split.map(&:to_i)
puts xarr.max < yarr.min && (x < xarr.max && yarr.min <= y) ? "No War" : "War"




Measured memory_bytes: 14280
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;

#define sorted(vector) sort(vector.begin(),vector.end())
#define vmin(vector) *min_element(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())

//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin>>n;
    long long tmp;
    A a(n,L(2,0));
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        a[i]={tmp,i+1};
    }
    sorted(a);
    for(int i=0  ;i<n  ;i++){
        cout<<a[i][1]<<" ";
    }
}

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

int main() {
   ll i,j,k;
    ll n,num=1;
    char iro;
    string s;
    cin >> n;
    cin >> s ;

iro=s[0];
    for(i=1; i<n; i++)
    {
      if(s[i]!=iro)
      {
        iro=s[i];
        num+=1;
      }
    }
  cout << num << endl;
}


Measured memory_bytes: 512
N, M = gets.split.map &:to_i
S, T = $<.map &:chomp

L = N.lcm M
h = {}
N.times{|i|
  h[L / N * i] = S[i]
}
p M.times.all?{|i|
  c = h[L / M * i]
  c.nil? || c == T[i]
} ? L : -1


Measured memory_bytes: 11772
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>


using namespace std;

int main(int, char**){
    int x;
    while(cin >> x,x){ 
	int vec[128];
	int cnt(0);
	for(int i(0);i<x;++i){
	    cin >> vec[i];
	}
	for(int i(x-1);i>0;--i){
	    for(int j(0);j<i;++j)
		if(vec[j] > vec[j+1]){ swap(vec[j],vec[j+1]); ++cnt; }
	}
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct LOC{

	int x,y;
};


int N,M;
LOC from[55],to[55];


int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){

		scanf("%d %d",&from[i].x,&from[i].y);
	}
	for(int i = 0; i < M; i++){

		scanf("%d %d",&to[i].x,&to[i].y);
	}

	for(int i = 0; i < N; i++){
		int min_dist = BIG_NUM;
		int index;

		for(int k = 0; k < M; k++){

			int tmp = abs(from[i].x-to[k].x)+abs(from[i].y-to[k].y);

			if(tmp < min_dist){
				min_dist = tmp;
				index = k;
			}
		}
		printf("%d\n",index+1);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    
		    if(a == 1) 
		    {
		    	if( b == 1 ) 
		    	{
		    		System.out.println("Draw");
		    	}
		    	else 
		    	{
		    		System.out.println("Alice");
		    	}
		    }
		    else 
		    {
		    	if( b == 1) 
		    	{
		    		System.out.println("Bob");
		    	}
		    	else 
		    	{
		    		if(a < b)
		    		{
		    			System.out.println("Bob");
		    		}
		    		else if( a == b) 
		    		{
		    			System.out.println("Draw");
		    		}
		    		else 
		    		{
		    			System.out.println("Alice");
		    		}
		    	}
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
n,k = map(int,input().split())
#a = [0 for _ in range(n)]
#b = [0 for _ in range(n)]
c = [[] for _ in range(n)]

for i in range(n - 1):
	A,B = map(int,input().split())
	#a[i] = A
	#b[i] = B
	c[A - 1].append(B - 1)
	c[B - 1].append(A - 1)

pat = k
pat_arr = [0 for _ in range(n)]
pat_arr[0] = k
queue = [0]



while(queue):
	pos = queue.pop(0)
	num = k-2
	if(pos == 0):num += 1
	
	for i in c[pos]:
		if(pat_arr[i] != 0):continue
		queue.append(i)
		pat_arr[i] = num
		pat *= num
		pat %= 1000000007
		num -= 1
		
		
print(pat % 1000000007)


Measured memory_bytes: 28856
#include "bits/stdc++.h"
using namespace std;
using namespace std;

char table[6][5] = {
	{'a','b','c','d','e'},
	{'f','g','h','i','j'},
	{'k','l','m','n','o'},
	{'p','q','r','s','t'},
	{'u','v','w','x','y'},
	{'z','.','?','!',' '}
};

int main(){
	string s;
	while( cin >> s ){
		string ans;
		if( s.size()%2 ){
			cout << "NA" << endl;
		}else{
			bool flag = false;
			for(int i=1 ; i < s.size() ; i+=2 ){
				int y = s[i-1]-'0'-1;
				int x = s[i]-'0'-1;
				if( y < 0 || x < 0 || y >= 6 || x >= 5 ){
					flag = true;
					break;
				}
				ans += table[y][x];
			}
			if( flag )
				cout << "NA" << endl;
			else
				cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.141592653589793238

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll inv(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

ll sum[100005];

int main() 
{
    FAST;
    ll n=0,k=0;
    cin>>n>>k;
    for(int i=k;i>=1;i--)
    {
        sum[i]=(sum[i]+(i*power(k/i,n,A))%A)%A;
        ll x=2;
        while(x*i<=k)
        {
            sum[i]=(sum[i]-((sum[x*i]*inv(x,A))%A)+A)%A;
            x++;
        }
    }
    ll ans=0;
    for(int i=1;i<=k;i++)
    {
        //cout<<sum[i]<<' '<<i<<'\n';
        ans=(ans+sum[i])%A;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4300
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <tuple>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    tuple<int, int, int> data[M];

    for (int i = 0; i < M; ++i) {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

    sort(data, data + M);

    int cnt[N + 1];
    fill(cnt, cnt + N + 1, 0);

    pair<int, int> id[M];

    for (int i = 0; i < M; ++i) {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        ++cnt[p];
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < M; ++i) {
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 3840
N = int(input())
a = list(map(int,input().split()))

from collections import Counter

c = Counter(a)
keys, values = zip(*c.most_common())

ans = 0

for i in range(len(keys)):
    if values[i] - keys[i] < 0:
        ans += values[i]
    else:
        ans += values[i] - keys[i]
        
print(ans)

Measured memory_bytes: 28404
import collections
import sys
sys.setrecursionlimit(1000000)


H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]


seen = [[False] * W for i in range(H)]
move = ((-1, 0), (1, 0), (0, -1), (0, 1))

q = collections.deque()


def bfs(i, j):
    b, w = 0, 0
    seen[i][j] = True
    q.append((i, j))

    while q:
        ci, cj = q.popleft()

        if S[ci][cj] == '#':
            b += 1
        else:
            w += 1

        for di, dj in move:
            ni = ci+di
            nj = cj+dj
            if 0 <= ni < H and 0 <= nj < W:
                if seen[ni][nj] is False and S[ci][cj] != S[ni][nj]:
                    seen[ni][nj] = True
                    q.append((ni, nj))

    return b*w


ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#' and seen[i][j] is False:
            ans += bfs(i, j)

print(ans)


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

int main() {
  int h,w;
  cin >> h >> w;
  rep(i,w+2) cout << "#";
  cout << "" << endl;
  rep(i,h){
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  rep(i,w+2) cout << "#";
  cout << "" << endl;
}

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

int main() {
  long long N,x;
  cin >> N >> x;
  
  vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  
  int count = 0;
  long long sum = 0;
  
 if (a.at(0) > x){
   cout << 0 << endl;
 }
 else {
  for (int i = 0; i < N; i++) {
    sum += a.at(i);
    count++;
    if (x < sum){
      cout << count - 1 << endl;
      break;
    }
    else if (i == N - 1 && x == sum){
      cout << N << endl;
      break;
    }
    else if (i == N - 1 && x > sum){
      cout << N - 1 << endl;
      break;
    }
  }
 }
}    
  



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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 5e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;


ll h[maxN];
ll power(ll x,ll p)
{
	if(p == 0)
	{
		return 1;
	}
	ll t = power(x,p/2);
	t = t*t%MOD;
	if(p%2 == 1)
	{
		t = t*x%MOD;
	}
	return t;
}
ll C(int n,int m)
{
	ll ans = h[n] * power(h[m],MOD-2) %MOD * power(h[n-m],MOD-2)%MOD;
	return ans;
}
ll rev(ll x)
{
	return power(x,MOD-2);
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	h[0] = 1;
	for(int i=1;i<=m;i++)
	{
		h[i] = (h[i-1]*i)%MOD; 
	}
	ll ans = 0;
	for(int k=0;k<=n;k++)
	{
		ll res = C(m,n) * C(n,k)%MOD * h[n] %MOD * h[m-k] %MOD * rev(h[m-n])%MOD;
		if(k%2)
		{
			ans -= res;
		}
		else
		{
			ans += res; 
		}
		ans = (ans+MOD)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7524
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	int c[4][4];
	int a[4], b[4];
	bool flag = true;

	FOR(i, 1, 3) {
		FOR(t, 1, 3) {
			cin >> c[i][t];
		}
	}

	FOR(i, 0, 100) {
		FOR(t, 0, 100) {
			if (i + t != c[1][1]) {
				continue;
			}
			else {
				a[1] = i;
				b[1] = t;
				b[2] = c[1][2] - i;
				b[3]= c[1][3] - i;
				a[2] = c[2][1] - t;
				a[3] = c[3][1] - t;
				FOR(s, 1, 3) {
					FOR(r, 1, 3) {
						if (a[s] + b[r] != c[s][r]) {
							goto warp;
						}
						else {
							if (s == 3 && r == 3) {
								cout << "Yes" << endl;
								flag = false;
								goto end;
							}
							continue;
						}
					}
				}
			warp:;
			}
		}
	}
end:;
	if (flag == true) {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long llong;

llong n,*lst;
string *lst_bin;
static const llong MOD = 1e+9 + 7;

void init(){
    cin>>n;
    lst = new llong[n];
    for(int i=0;i<n;i++)cin>>lst[i];
}

void solve(){
    llong cnt_1[60] = {}, cnt_0[60] = {};
    for(int i=0;i<n;i++){
        for(int j=0;j<60;j++){
            cnt_1[j] += (lst[i] >> j) & 0x1;
        }
    }
    for(int i=0;i<60;i++)cnt_0[i] = n - cnt_1[i]; 
    llong ans=0;
    llong x = 1;
    for(int i=0;i<60;i++){
        llong cnt_0_i = cnt_0[i];
        llong cnt_1_i = cnt_1[i];
        ans += (((cnt_0_i * cnt_1_i) % MOD )* x) % MOD ;
        ans %= MOD;
        x = (x * 2) % MOD;
    }
    cout<<ans<<endl;
}

int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    int cur=1;
    if(cur>=b){
        cout << 0 << endl;
        return 0;
    }
    int ans;
    for(int i=1;i<=100;i++){
        cur+=(a-1);
        if(cur>=b){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;

int main(int argc, char *argv[])
{
  char x,y;
  map<char,int> Map;
  int temp;
  Map['A'] = 1;
  while(scanf("%c,%c",&x,&y) !=EOF){
   temp = Map[x];
   Map[x] = Map[y];
   Map[y] = temp;
  }
  for(char i ='A';i<='C';i++){
    if(Map[i] ==1)
      cout <<i<<endl;
    }
  return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

LL allXor(LL n)
{
	if (n < 0) {return 0;}
	// 1からnまでのxor
	switch (n%4) {
		case 0:
			return n;
		case 1:
			return 1;
		case 2:
			return n+1;
		case 3:
			return 0;
		default:
			return -1;
	}
}

int main(int argc, char *argv[])
{
	LL a,b;
	cin >> a >> b;
	cout << (allXor(a-1) ^ allXor(b)) << endl;
	return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: u32 = read_as_vec()[0];

    println!("{}", (n+1)/2);
}


Measured memory_bytes: 4352
def judge(a):
    ans=0
    while a%2==0:
        a/=2
        ans+=1
    return ans

if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    count=0
    for a in A:
        count+=judge(a)

    print(count)




Measured memory_bytes: 4148
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  string s;
  cin >> n >> s;
  // vector<bool> f(1000, false);
  ll ans = 0;
  REP(i, 1000) {
    vector<int> t(3);
    t[0] = i / 100;
    t[1] = (i - t[0] * 100) / 10;
    t[2] = i - 100 * t[0] - 10 * t[1];
    int c = 0;
    REP(j, n) {
      int a = s[j] - '0';
      if (c == 0 && a == t[0]) {
        c++;
        continue;
      }
      if (c == 1 && a == t[1]) {
        c++;
        continue;
      }
      if (c == 2 && a == t[2]) {
        ans++;
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3660
#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> a(N), b(N);
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];
  ll cnt = 0;
  rep(i, N) {
    if(a[i] > b[i]) {
      cnt += a[i]-b[i];
      b[i] = a[i];
    }
  }
  rep(i, N) {
    if(a[i] < b[i]) {
      cnt -= (b[i]-a[i])/2;
      a[i] += (b[i]-a[i])/2*2;
    }
  }
  if(cnt <= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    cout << x2 - dy << ' ' << y2 + dx << ' ' << x1 - dy << ' ' << y1 + dx;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int h,w;

vvec field(50,vec(50,'#'));
vvi dist(50,vi(50,INF));

int bfs(){
    queue<i_i> que;
    que.push({0,0});
    dist[0][0]= 0;
    while(!que.empty()){
        i_i  c = que.front(); que.pop();
        //cout << c.fs << c.sc << endl;
        if(c.fs == h && c.sc == w) break;
        rep(i,4){
            int nx = c.fs + dx[i], ny = c.sc+dy[i];
            if(0<=nx && nx <= h && 0<= ny && ny <= w && field[nx][ny] != '#' && dist[nx][ny] == INF){
                //cout << nx << ny << endl;
                que.push({nx,ny});
                dist[nx][ny] = dist[c.fs][c.sc] + 1; 
            }
        }
    }
    return dist[h][w];
}


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


    cin >> h >> w;
    --h,--w;
    int cnt = 0;
    rep(i,h+1){
        rep(j,w+1){
            cin >> field[i][j];
            if(field[i][j] == '.') ++cnt;
        }
    }
    if(bfs()==INF) dame;
    cout << cnt - dist[h][w] - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;

    cin >> N;

    int a[N];

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

    for(int val : a)
    {
        if(val % 2 == 0 && !(val % 3 == 0 || val % 5 == 0))
        {
            cout << "DENIED" << endl;

            return 0;
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}


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

using namespace std;

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

	int n, k;
	string s;
	cin >> n >> k >> s;

	int ct = 1;
	for(int i = 1; i < n; i++) {
		if(s[i] != s[i-1]) ++ct;
	}

	cout << n - max(1, ct-2*k);
	return 0;
}




Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void){
	int h1,h2,k1,k2,a,b,c,d,hp,kp;
	cin >> h1 >> h2;
	cin >> k1 >> k2;
	cin >> a >> b >> c >> d;
	
	hp = h1*a;
	h1 /= 10;
	h1 *= c;
	hp += h1;
	hp += h2*b;
	h2 /= 20;
	h2 *= d;
	hp += h2;
	
	kp = k1*a;
	k1 /= 10;
	k1 *= c;
	kp += k1;
	kp += k2*b;
	k2 /= 20;
	k2 *= d;
	kp += k2;
	
	if(kp>hp){
		cout << "kenjiro" << endl;
	} else if(hp>kp){
		cout << "hiroshi" << endl;
	}else{
		cout << "even" << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int N ;
  cin >> N ;
  string line[N] ;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  bool ans = true ;
  for(int i = 0 ; i < N - 1 ; i++ )
    if(line[i][line[i].size()-1]!=line[i+1][0])
      ans = false ;
  for(int i = 0 ; i < N ; i++ ){
    for(int j = i + 1; j < N ; j++ ){
      if(line[i]==line[j])
        ans =false ;
    }
  }
  if(ans) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
sum_Alice = 0
sum_Bob = 0
for i in range(N):
    if i % 2 == 0:
        sum_Alice += a[i]
    else:
        sum_Bob += a[i]
print(sum_Alice - sum_Bob)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b){
      cout <<"YES";
    }else{
      cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N,M;
int dist[1010];
bool negative[1010];
struct edge{int from,to,cost;};
edge G[2010];

signed main(void){
    
    cin>>N>>M;
    rep(i,M){
        edge e;
        cin>>e.from>>e.to>>e.cost;
        e.from--; e.to--; e.cost=-e.cost;
        G[i]=e;
    }
    
    fill(dist,dist+N,INF);
    dist[0]=0;
    rep(i,N-1){
        rep(j,M){
            if(dist[G[j].from]==INF)continue;
            if(dist[G[j].to]>dist[G[j].from]+G[j].cost){
                dist[G[j].to]=dist[G[j].from]+G[j].cost;
            }
        }
    }
    
    rep(i,N){
        rep(j,M){
            if(dist[G[j].from]==INF)continue;
            if(dist[G[j].to]>dist[G[j].from]+G[j].cost){
                dist[G[j].to]=dist[G[j].from]+G[j].cost;
                negative[G[j].to]=true;
            }
            if(negative[G[j].from])negative[G[j].from]=true;
        }
    }
    
    int ans=-dist[N-1];
    if(negative[N-1])cout<<"inf\n";
    else cout<<ans<<endl;
    
}

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

int main(){
  ll n,k;
  cin >> n >> k;
  double Log = log(n)/log(k);
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  cout << ceil(Log) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

char A[11];
char B[11];
char C[11];

int main() 
{
	int i;
	int rtn;
	char cA;
	char cB;

	rtn = scanf("%s %s %s", A, B, C);

	//　最後の文字を見つける
	for (i = 0; i < 11; i++) {
		if (A[i] == '\0') {
			cA = A[i - 1];	//Aの終端
			break;
		}
	}
	for (i = 0; i < 11; i++) {
		if (B[i] == '\0') {
			cB = B[i - 1];	//Bの終端
			break;
		}
	}

	if (cA == B[0] && cB == C[0]) {
		printf("YES");
	}
	else {
		printf("NO");
	}


	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

int calculate_distance2 (int const& val_dimension, std::vector<int> const& point_orign, std::vector<int> const& point_target)
{
	// return value of this function
	int distance2;
	int difference;

	distance2 = 0;

	for (int itr = 0; itr < val_dimension; itr++)
	{
		difference  = point_target.at(itr) - point_orign.at(itr);
		difference *= difference;
		distance2  += difference;
	}

	return distance2;
}

bool is_GoodDist (int const& val_dist)
{
	// variables for this function
	int itr_int  = 0;
	int itr_int2 = 0;

	while (itr_int2 <= val_dist)
	{
		if (itr_int2 == val_dist) { return true; }
		itr_int++;
		itr_int2 = itr_int * itr_int;
	}

	return false;
}

int calculate_num_GoodDist (int const& num_points, int const& val_dimension, std::vector<std::vector<int>> const& coordinate)
{
	// variables for this function
	int num_GoodDist;

	// STEP.01
	// initialize the variable
	num_GoodDist = 0;

	for (int itr_orign  = 0;             itr_orign  < num_points - 1; ++itr_orign ) {//
	for (int itr_target = itr_orign + 1; itr_target < num_points;     ++itr_target) {//
		if ( is_GoodDist( calculate_distance2(val_dimension, coordinate.at(itr_orign), coordinate.at(itr_target)) ) ) { num_GoodDist++; }
	}
	}

	return num_GoodDist;
}

int main (void)
{
	// variables for main process
	int num_points;
	int val_dimension;

	// STEP.01
	// read out the given data
	std::cin >> num_points >> val_dimension;

	// STEP.02
	// declare the <vector> object to store the given data
	std::vector<std::vector<int>> coordinate(num_points, std::vector<int>(val_dimension)); ;

	// STEP.03
	// read out the given data
	for (int itr_point = 0; itr_point < num_points;    itr_point++) {//
	for (int itr_dmsn  = 0; itr_dmsn  < val_dimension; itr_dmsn++ ) {//
		std::cin >> coordinate[itr_point][itr_dmsn];
	}
	}

	std::cout << calculate_num_GoodDist (num_points, val_dimension, coordinate) << std::endl;

	// STEP.END
	return 0;
}

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

using namespace std;

int main(){
    
    map<string,int> mp;
    
    int N;
    cin>>N;
    
    for(int i=0;i!=N;++i){
        string str;
        cin>>str;
        ++mp[str];
        
    }
    int max=0;
    for(auto a=mp.begin();a!=mp.end();++a){
        max=(max>=a->second)?max:a->second;
    }
    
    for(auto a=mp.begin();a!=mp.end();++a){
        if(max==a->second){
            cout<<a->first<<endl;
        }
    }
}

Measured memory_bytes: 25216
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

void solve()
{
	int n;
	scanf("%d\n", &n);
	string name = "Hoshino";
	while(n--)
	{
		string s;
		getline(cin, s);
		int length = s.length() - name.length() + 1;
		for(int i = 0; i < length; ++i)
		{
			bool flag = true;
			for(int j = 0; j < name.length(); ++j)
			{
				if(s[i + j] != name[j])
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				s[i + name.length() - 1] = 'a';
			}
			else
			{
				continue;
			}
		}
		cout << s << endl;
	}
}

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

Measured memory_bytes: 1236
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int nxt[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int n, m, cn, cm, dn, dm, ans;
char s[1005][1005];
int inque[1005][1005], dis[1005][1005];

struct Node {
	int x, y, dis;
	Node() {}
	Node(int a, int b, int c) : x(a), y(b), dis(c) {}
	~Node() {}
	friend bool operator < (const Node &a, const Node &b) {
		return a.dis > b.dis;
	}
};
priority_queue<Node> q;

void floodFillDfs(int x, int y, int d) {
	dis[x][y] = d;
	if(!inque[x][y]) {
		q.push(Node(x, y, d));
		inque[x][y] = 1;
	}
//	printf("FLOODFILLDFS(%d, %d, %d)\n", x, y, d);
	for(int i=0;i<4;i++) {
		int tx = x + nxt[i][0];
		int ty = y + nxt[i][1];
		if(tx < 1 || tx > n || ty < 1 || ty > m || s[tx][ty] == '#' || dis[tx][ty] <= d) continue;
		floodFillDfs(tx, ty, d);
	}
}
void bfs() {
	while(!q.empty()) {
		int x = q.top().x, y = q.top().y;
		q.pop();
		for(int i=0;i<4;i++) {
			int tx = x + nxt[i][0];
			int ty = y + nxt[i][1];
			if(tx < 1 || tx > n || ty < 1 || ty > m || s[tx][ty] == '#' || dis[tx][ty] <= dis[x][y]) continue;
			floodFillDfs(tx, ty, dis[x][y]);
		}
		for(int i=-2;i<=2;i++) {
			for(int j=-2;j<=2;j++) {
				int tx = x + i;
				int ty = y + j;
				if(tx < 1 || tx > n || ty < 1 || ty > m || s[tx][ty] == '#' || dis[tx][ty] <= dis[x][y] + 1) continue;
				floodFillDfs(tx, ty, dis[x][y]+1);
			}
		}
		if(dis[dn][dm] != 0x3f3f3f3f) return;
	}
}

int main() {
	scanf("%d%d", &n, &m);
	scanf("%d%d", &cn, &cm);
	scanf("%d%d", &dn, &dm);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			s[i][j] = getchar();
			while(s[i][j] != '.' && s[i][j] != '#') s[i][j] = getchar();
			dis[i][j] = 0x3f3f3f3f;
		}
	}
	floodFillDfs(cn, cm, 0);
	bfs();
	if(dis[dn][dm] == 0x3f3f3f3f) puts("-1");
	else printf("%d\n", dis[dn][dm]);
	return 0;
}

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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int iteration, biscuit, time;
    
    cin >> iteration >> biscuit >> time;
    
    cout << biscuit * (time / iteration);
    
	return 0;
}


Measured memory_bytes: 256