akhauriyash/Code-Regression huggingface dataset:
from operator import itemgetter

n = int(input())
p = [input().split() for l in range(n)]
for i in range(0,n):
    p[i].insert(0,i+1)
    p[i][2] = int(p[i][2])

p.sort(key=itemgetter(2),reverse=True)
p.sort(key=itemgetter(1))
for i in range(0,n):
    print(p[i][0])

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


int main() {
    int n, k;
    cin >> n >> k;
    ll ans = k;
    rep1(i,n){
        ans *= k - 1;
    }
    cout << ans << endl;
}

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

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

    vector<long long > diff(N - 1);
    for (int i = 0; i < N - 1; i++)
        diff[i] = X[i + 1] - X[i];

    long long res = 0;
    for (int i = 0; i < N - 1; i++) {
        if (diff[i] * A < B) {
            res += diff[i] * A;
        } else {
            res += B;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
main(){
	int n,m,s,t,c,i;
	for(;cin>>n>>m,n;){
		map<int,vector<P> >E;
		for(i=0;i<m;i++){
			cin>>s>>t>>c;
			E[s].push_back(make_pair(c,t));
			E[t].push_back(make_pair(c,s));
		}
		map<int,int>v;
		vector<int>a;
		priority_queue<P,vector<P>,greater<P> >Q;
		Q.push(make_pair(0,1));
		for(;!Q.empty();){
			P p=Q.top();Q.pop();
			if(!v[p.second]){
				v[p.second]=1;
				a.push_back(p.first);
				for(i=0;i<E[p.second].size();i++)Q.push(make_pair(E[p.second][i].first,E[p.second][i].second));
			}
		}
		sort(a.begin(),a.end());
		cout<<a[n/2]<<endl;
	}
}

Measured memory_bytes: 1796
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
    tmp_p = [0] * 102
if n == 0:
    print(x)
else:
    for i in range(n):
        tmp_p[p[i]] += 1
    if tmp_p[x] == 0:
        print(x)
    else:
        j = 1
        stop_min = 0
        stop_max = 0
        while stop_min == 0 or stop_max == 0:
            if x-j >= 0:
                if tmp_p[x-j] == 0:
                    print(x-j)
                    break
            else:
                stop_min += 1
            if x+j <= 101:
                if tmp_p[x+j] == 0:
                    print(x+j)
                    break
            else:
                stop_max += 1
            j += 1


Measured memory_bytes: 9208
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n, m;cin >> n >> m;
	int a[n][m];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++)cin >> a[i][j];
	}
	int b[m];
	for(int i = 0; i < m; i++)cin >> b[i];
	for(int i = 0; i < n; i++){
		int now = 0;
		for(int j = 0; j < m; j++)now += a[i][j] * b[j];
		cout << now << '\n';
	}
	return 0;
}



Measured memory_bytes: 3224
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;
  cin >> N;
  cout << (N - 1) / 2 << endl;
  return 0;
}


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


/*
a,b
c,d
e,f

a=0,b=0で固定すると、s=|cf-de|
さらに、c=10^9,d=1で固定すると、
s=|10^9*f-e|=|10^9*(f-1) + 10^9-e|
sを10^9で割った商をf-1,余りを10^9-eとすれば良い
ただし、s=10^18の時、fが10^9を超過する。この時、f=10^9,e=0とすればいい
*/


void solve(){
    ll s;
    cin >> s;
    ll a,b,c,d,e,f;
    a=0;
    b=0;
    c=1000000000;
    d=1;
    e=c-s%c;
    f=s/c+1;
    if(f>c) {
        f=c;
        e=0;
    }
    cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
}

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


Measured memory_bytes: 256
n = gets.to_i
dices = []
n.times do
  dices << gets.split.map(&:to_i)
end
max_zoro_count = 0
current_zoro_count = 0
dices.each do |a, b|
  if a == b
    current_zoro_count += 1
  else
    current_zoro_count = 0
  end
  max_zoro_count = [max_zoro_count, current_zoro_count].max
end
if max_zoro_count >= 3
  puts "Yes"
else
  puts "No"
end


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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define nfirst(_obj, _n)              (_obj).begin(), (_obj).begin() + (_n)
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define div_ceil(_dividend, _divider) ((_dividend) - 1LL + (_divider)) / (_divider)
#define sz(_obj)                      static_cast<int>((_obj).size())
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = std::int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = 1e9 + 7;

//.data
const int SIZE = 55;
vector<int> gr[SIZE];
int cntBridges;
int tIn[SIZE], fUp[SIZE];
char used[SIZE];
int T;

void findBridge(int from = 0, int p = -1) {
    tIn[from] = fUp[from] = T++;
    used[from] = true;

    loop(sz(gr[from])) {
        int to = gr[from][i];
        if (used[to]) {
            if (to != p) {
                fUp[from] = min(fUp[from], tIn[to]);
            }
            continue;
        }
        findBridge(to, from);
        fUp[from] = min(fUp[from], fUp[to]);
        if (fUp[to] > tIn[from]) {
            ++cntBridges;
        }
    }
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream сin  ("input.txt",  std::ios::in);
    std::ofstream сout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    loop(m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }

    findBridge();

    cout << cntBridges;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= 13) cout << B << endl;
    else if (A >= 6) cout << B / 2 << endl;
    else cout << 0 << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 110;
const double eps = 1e-6;

int n;
int x[N], y[N], h[N];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0)
        {
            swap(x[0], x[i]);
            swap(y[0], y[i]);
            swap(h[0], h[i]);
        }
    }

    for(int i = 0; i <= 100; i++)
        for(int j = 0; j <= 100; j++)
        {
            int H = h[0] + abs(x[0] - i) + abs(y[0] - j);
            bool flag = true;

            for(int k = 0; k < n; k++)
                if(max(H - abs(x[k] - i) - abs(y[k] - j), 0) != h[k])
                {
                    flag = false;
                    break;
                }

            if(flag)
            {
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
        }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
    int src,to;
    T cost,coin;

    edge() = default;
    edge(int to, T cost, T coin) : src(-1), to(to), cost(cost), coin(coin) {}
    edge(int src, int to, T cost, T coin) : src(src), to(to), cost(cost), coin(coin) {}
    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

const int MAX = 10000;
using Tu = tuple<ll, ll, ll>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,M,S; cin >> N >> M >> S;
    vector<vector<edge<ll>>> G(N);
    rep(i,M) {
        int u,v,a,b; cin >> u >> v >> a >> b;
        --u; --v;
        G[u].emplace_back(v,b,a);
        G[v].emplace_back(u,b,a);
    }
    vector<ll> C(N),D(N);
    rep(i,N) cin >> C[i] >> D[i];

    
    vector<vector<ll>> dist(N, vector<ll>(MAX,4e18));
    chmin(S,MAX-1);
    dist[0][S] = 0;
    priority_queue<Tu, vector<Tu>, greater<Tu>> pq;
    pq.emplace(make_tuple(0,0,S));
    while (!pq.empty()) {
        ll d,v,c;
        tie(d,v,c) = pq.top(); pq.pop();
        if (d > dist[v][c]) continue;
        for (auto &e : G[v]) {
            if (c < e.coin) continue;
            if (chmin(dist[e.to][c-e.coin],dist[v][c]+e.cost)) {
                pq.emplace(make_tuple(dist[e.to][c-e.coin], e.to, c-e.coin));
            }
        }
        if (c+C[v] < MAX) {
            if (chmin(dist[v][c+C[v]],dist[v][c]+D[v])) {
                pq.emplace(make_tuple(dist[v][c+C[v]], v, c+C[v]));
            }
        }
    }

    for (int i = 1; i < N; i++) {
        ll val = 4e18;
        rep(j,MAX) chmin(val,dist[i][j]);
        cout << val << ln;
    }
}

Measured memory_bytes: 19540
#include <iostream>
using namespace std;
int main()
{
	int i,n,num[10010];
	cin>>n;
	for(i=0;i<n;i++)
	cin>>num[i];
	for(int j=i-1;j>=0;j--)
	{
		if(j<i-1)
		cout<<" ";
		cout<<num[j];
	}
	
	cout<<endl;
	return 0;
 } 


Measured memory_bytes: 3100
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int x[100100], y[100100];

int solve() {
    int cnt[n];
    for (int i = 0; i < n; i++) cnt[i] = 1;
    bool red[n];
    memset(red, false, sizeof(red));
    red[0] = true;

    for (int i = 0; i < m; i++) {
        if (red[x[i]]) {
            red[y[i]] = true;
            if (cnt[x[i]] == 1) red[x[i]] = false;
        }

        cnt[x[i]]--;
        cnt[y[i]]++;
    }

    int res = 0;
    for (int i = 0; i < n; i++) res += red[i];
    return res;
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

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

    if (find(s.begin(), s.end(), 'R') == s.end()) {
        cout << 0 << endl;
    }
    else if (s.find("RRR") != string::npos) {
        cout << 3 << endl;
    }
    else if (s.find("RR") != string::npos) {
        cout << 2 << endl;
    }
    else {
        cout << 1 << endl;
    }
}


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

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

    int x[3];
    x[0] = a;
    x[1] = b;
    x[2] = c;

    sort(x, x + 3, greater<int>());
    int max_num = x[0];
    int ans = x[1] + x[2];
    for ( int i = 0; i < k; i++){
        max_num *= 2;
    }
    ans += max_num;
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [10**10 for i in range(n)]
dp[0] = 0
for i in range(n):
    if i + 1 < n:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    if i + 2 < n:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
print(dp[n - 1])

Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a, min(b, c)) << " " << max(a, max(b, c)) << endl;
    return 0;
} 


Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100001)
#define MOD (1000000007)

bool s[MAXN];
ll ans[MAXN+1];

int main(void)
{
    ll n,m;
    scanf("%ld %ld",&n,&m);
    for(int i=0;i<m;i++)
    {
        ll a;
        scanf("%ld",&a);
        s[a] = true;
    }

    ans[0] = 1;
    for(int i=1;i<=n;i++)
    {
        if(s[i-1]==false)
        {
            ans[i] += ans[i-1];
            ans[i] %= MOD;
        }

        if(i>=2&&s[i-2]==false)
        {
            ans[i] += ans[i-2];
            ans[i] %= MOD;
        }
    }

    printf("%ld\n", ans[n]);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define F first
#define S second
#define MP make_pair
struct edge
{
	int to, cost, cnt;
	edge(int a, int b, int c)
	{
		to = a; cost = b; cnt = c;
	}
};
int N, K;
int c[5000], r[5000];
int flag2[5001];
vector<int> G[5001], G2[5001];
priority_queue<P, vector<P>, greater<P> > pq;
void bfs(int s)
{
	queue<P> que;
	que.push(MP(s, 0));
	bool flag[5001] ={};
	flag[s] = true;
	while(!que.empty())
	{
		P now = que.front();
		que.pop();
		if(now.S == r[s]) continue;
		for(int i = 0; i < G[now.F].size(); ++i)
		{
			if(!flag[G[now.F][i]])
			{
				flag[G[now.F][i]] = true;
				que.push(MP(G[now.F][i], now.S + 1));
				G2[s].push_back(G[now.F][i]);
			}
		}
	}
}
void dijkstra(int s)
{
	pq.push(MP(0, 0));
	while(!pq.empty())
	{
		P now = pq.top();
		pq.pop();
		for(int i = 0; i < G2[now.S].size(); ++i)
		{
			if(flag2[G2[now.S][i]] > now.F + c[now.S])
			{
				flag2[G2[now.S][i]] = now.F + c[now.S];	
				pq.push(MP(now.F + c[now.S], G2[now.S][i]));
			}
		}
	}
}
int main()
{
	cin >> N >> K;
	for(int i = 0; i < N; ++i)
		cin >> c[i] >> r[i];
	for(int i = 0; i < K; ++i)
	{
		int in1, in2;
		cin >> in1 >> in2;
		--in1; --in2;
		G[in1].push_back(in2);
		G[in2].push_back(in1);
	}
	fill(flag2 + 1, flag2 + N, INT_MAX);
	for(int i = 0; i < N; ++i)
		bfs(i);
	dijkstra(0);
	cout << flag2[N - 1] << endl;
}

Measured memory_bytes: 70576
import copy

H,W,Q = map(int,input().split())
c = [list(input()) for _ in range(H)]
kotei = copy.deepcopy(c)
ans = 0

K = 2 # 選択肢の数
N = H+W # 問題の個数
for i in range(K**N):
    TF=[0]*N
    c = copy.deepcopy(kotei)

    for j in range(N):
        TF[N-j-1] = i % K
        i //= K
    
    #print(TF)
    for j in range(len(TF)):
        if TF[j] == 1 and 0 <= j < H:
            c[j] = ["R"]*W
        if TF[j] == 1 and j >= H:
            j -= H
            for k in range(H):
                c[k][j] = "R"

    #print(c)
    black = 0
    for j in range(H):
        for k in range(W):
            if c[j][k] == "#":
                black += 1
    if black == Q:
        ans += 1

print(ans)

Measured memory_bytes: 76128
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int a[200005];
int b[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(a+1,a+1+n);
    int m=n/2;
    for(int i=1;i<=n;i++)
    {
        if(b[i]<=a[m])
            printf("%d\n",a[m+1]);
        else
            printf("%d\n",a[m]);
    }
    return 0;
}

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

int main(){
    int i,n,tcount = 0,hcount = 0;
    string taro,hanako;

    cin >> n;
    for (i = 0; i < n; i++){
        cin >> taro >> hanako;
        if ( taro > hanako){
            tcount += 3;
        }
        else if (taro < hanako){
            hcount += 3;
        }
        else if (taro == hanako){
            tcount += 1;
            hcount += 1;
        }
    }
    cout << tcount << " " << hcount << '\n'; 
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a;
	cin >> a;
	for (int z=0;z<3;z++){
		if (a[z] == a[z+1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    bool good = true;
    FOR(i, 0, S.size()) {
        if (i % 2 == 0 && S[i] == 'L')
            good = false;
        if (i % 2 == 1 && S[i] == 'R')
            good = false;
    }

    cout << (good ? "Yes" : "No") << endl;
    return 0;
};


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

  int i;
  long long int N,M,sum;
  long int A[10000];

  sum = 0;
  
  scanf("%lld %lld",&N,&M);
  for(i=0;i<M;i++)
  {
    scanf("%ld",&A[i]);
    sum = sum + A[i];
  }
  if(N-sum>=0)
  {
  printf("%ld",N-sum);
  }else{printf("-1");}
  return 0;
}

Measured memory_bytes: 1804
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] list = Console.ReadLine().Split();
            int sum = 0;
            int max = 0;

            for (var i = 0; i < n;i++)
            {
                int useNum = int.Parse(list[i]);
                sum += useNum;
                if(useNum > max)
                {
                    max = useNum;
                }
            }
            if(max<sum-max)
            {
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : num( 0 ), result( 0 ), prev( NULL ), next( NULL ){}

	int num, result;
	tCell *prev, *next;
};

class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ), rankList( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev =head;
	}
	~MyArray(){
		init();
		SAFE_DELETE( rankList );
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = mSize; i > 0; --i ){
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
		mSize = 0;
		if ( rankList ){
			SAFE_DELETE( rankList );
			rankList = new MyArray;
		}
	}
	void pushBack( int n, int r ){
		++mSize;
		tCell* cell = new tCell;
		cell->num = n;
		cell->result = r;
		cell->prev = tail->prev;
		cell->next =tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}
	void createRank(){
		rankList = new MyArray;
		rankList->init();
		tCell* cell = head;
		for ( int i = 0; i < mSize; ++i ){
			cell = cell->next;
			if ( !rankList->find( cell->result ) ){
				rankList->pushBack( 0, cell->result );
			}
		}
		rankList->sort();
	}
	bool find( int index ){
		tCell* cell = head;
		for ( int i = 0; i < mSize; ++i ){
			cell = cell->next;
			if ( index == cell->result ) return true;
		}
		return false;
	}
	void sort(){
		for ( int i = 0; i < mSize-1; ++i ){
			tCell* cell = head;
			for ( int j = 0; j < mSize-1-i; ++j ){
				cell = cell->next;
				if ( cell->result < cell->next->result ){
					int t = cell->result;
					cell->result = cell->next->result;
					cell->next->result = t;
				}
			}
		}
	}
	int size(){ return mSize; }
	int getRank( int index ){
		tCell* cell = head;
		for ( int i = 0; i < mSize; ++i ){
			cell = cell->next;
			if ( index == cell->num ) break;
		}
		for ( int i =0; i < rankList->size(); ++i ){
			if ( cell->result == (*rankList)[ i ].result ) return i+1;
		}
		return 0;
	}

	tCell operator[]( int index ){
		tCell* cell = head->next;
		for ( int i = 0; i < index; ++i ){
			cell = cell->next;
		}
		return *cell;
	}

private:

	int mSize;
	tCell *head, *tail;
	MyArray* rankList;
};

int main(){
	int num, result;
	char c;
	MyArray list;

	while ( cin >> num >> c >> result ){
		if ( !num && !result ) break;
		list.pushBack( num, result );
	}
	list.createRank();

	while ( cin >> num ){
		cout << list.getRank( num ) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split("/");
			int y = Integer.parseInt(chr[0]);
			int m = Integer.parseInt(chr[1]);

			 System.out.println(y<=2019&&m<5?"Heisei":"TBD");
		}
	}
}

Measured memory_bytes: 25396
def dfs(formula, index, sum_number):
    if index + 1 == max_index:
        if sum_number == 7:
            print(formula + "=7")
            exit()

    else:
        dfs(formula + "+" + S[index + 1], index + 1, sum_number + int(S[index + 1]))
        dfs(formula + "-" + S[index + 1], index + 1, sum_number - int(S[index + 1]))


S = input()
max_index = len(S)
print(dfs(S[0], 0, int(S[0])))

Measured memory_bytes: 38256
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
string s;
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
//......Code.............
int main()
{
    cin>>s;
    cout<<s.substr(0,s.SZ-8);
    return 0;
}


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

int main() {

    int h,n;

    cin >> h >> n;

    vector<int> a(n);

    int sum_a = 0;
    for (int i=0;i<n;i++){
        cin >> a.at(i);
        sum_a += a.at(i);
    }

    if (sum_a >= h) cout << "Yes" << endl;
    else cout << "No" << endl;   
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000010000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 200105
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 2*acos(0)
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<pii, vector<pii > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pair<string,string> , null_type, less<pair<string,string> >, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
ll ar[ 6 ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    for ( ll i = 1; i <=5 ;i ++){
        cin >> ar[i];
    }
    for ( ll i = 1; i <= 5; i ++){
        if ( ar[i] == 0 ){
            cout << i;
            return 0;
        }
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N), C(N);
	vector<pair<int, int>> B(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		B[i] = { A[i],i };
	}
	sort(all(B));
	for (int i = 0;i < N;i++) {
		C[i] = B[i].second;
	}
	int ans = INT32_MAX;
	set<int> S;
	S.insert(-1);
	S.insert(N);
	vector<int> V;
	priority_queue<int> P, PS;
	for (int i = 0;i < N;i++) {
		V = A;P = PS;
		for (auto it = S.begin();it != S.end();it++) {
			auto it2 = it;it2++;
			if (*it2 != *it + 1) {
				sort(V.begin() + *it + 1, V.begin() + *it2);
			}
			if (*it2 >= N)break;
			V[*it2] = -1;
		}
		int cnt = 0;
		for (int j = N - 1;j >= 0;j--) {
			if (V[j] < 0) {
				cnt = 0;
				continue;
			}
			cnt++;
			if (cnt > K - 1) {
				P.push(-V[j]);
			}
		}

		if (P.empty())break;
		int f = -P.top(), s;
		for (int j = 0;j < Q - 1;j++) {
			if (P.empty())
				break;
			P.pop();
		}
		if (P.empty())break;
		s = -P.top();
		ans = min(ans, s - f);
		S.insert(C[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 101010
#define inf 1000000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int arr[105];
ll lcm(ll a, ll b)
{
  ll hcf = __gcd(a,b);
  b/=hcf;
  return (a*b);
}
int main(){
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  ll x;
  ll ans  = 1;
  for(int i = 1;i <= n;i++)
  {
    cin >> x;
    ans = lcm(ans,x);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
signed main() {
	int n; cin >> n;
	for (int i = 0; i <= n; i++) {
		if ((int)(i*1.08) == n) {
			cout << i << "\n";
			return 0;
		}
	}printf(":(\n");
}

Measured memory_bytes: 256
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, m = map(int, input().split())

if n < 2:
    if m < 2:
        ans = 0
    else:
        ans = combinations_count(m, 2)
else:
    if m < 2:
        ans = combinations_count(n, 2)
    else:
        ans = combinations_count(n, 2) + combinations_count(m, 2)
print(ans)

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

using namespace std;

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

const ld pi = 3.141592653589793;

int n, x, t;

int main() {
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;
ll gcd(ll x,ll y){
   return y ? gcd( y , x%y ) : x;
}



int main(){
    int n;  cin >> n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;i++){
        cin >> a.at(i);
    }
    
    ll l[n+1],r[n+1];
    l[0]=0;
    r[n+1]=0;

    for(int i=1;i<=n;i++){
        l[i]=gcd(l[i-1],a[i-1]);
        
    }
    for(int i=n;i>=0;i--){
        r[i] = gcd(r[i+1],a[i]);
    }

    ll ans=-1;
    for(int i=0;i<=n;i++){
        ans=max( ans,gcd(l[i],r[i+1]) );
    }

    cout << ans << endl;


}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main(){
    int n;
    scanf("%d", &n);
    vector<vector<int>> town(n, vector<int>(2, 0));
    rep(i, n) rep(j, 2) scanf("%d", &town[i][j]);

    
    vector<vector<ld>> length(n, vector<ld>(n, 0));
    rep(i, n) rep(j, n) length[i][j] = sqrt(pow(town[i][0]-town[j][0], 2)+pow(town[i][1]-town[j][1], 2));
    
    ld ans = 0;
    vector<int> array(n);
    rep(i, n) array[i] = i;
    
    do{
        rep(i, n-1){
            ans += length[array[i]][array[i+1]];
        }
    }while(next_permutation(all(array)));
    
    rep(i, n) ans /= i+1;
    
    printf("%.10Lf\n", ans);
           
/**/
    return 0;
}

Measured memory_bytes: 3860
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int mod = 1e9 + 7;
//const int inf = 2e9 + 6555;
//const int maxn = 1e5 + 55;


signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int x;
    cin >> x;
    cout << 8 - ((x - 400) / 200);

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define vi vector<int>

int main(void){
  int n,a,b,u;
  string s;
  cin>>n>>a>>b>>s;
  u = a + b;
  rep(i,s.size()){
    if(s[i] == 'c'){
      cout<<"No"<<endl;
      continue;
    }
    if(u > 0 && s[i] == 'a'){
      cout<<"Yes"<<endl;
      u --;
      continue;
    }else if(u > 0 && b > 0 && s[i] == 'b'){
      cout<<"Yes"<<endl;
      u --; b --;
      continue;
    }
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 896
import java.util.regex.Pattern

fun main(args: Array<String>) {
    val charCount = readLine()!!.toInt()
    val text = readLine()!!
    val regex = Pattern.compile("ABC")
    val matcher = regex.matcher(text)
    var i = 0
    while(matcher.find()) {
        i++
    }
    println(i)
}

Measured memory_bytes: 31392
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double a,b,c,PI=3.1415926535;
  cin >> a >> b >> c;
  printf("%.5f\n",a*b*sin(c*PI/180)/2);
  printf("%.5f\n",sqrt(a*a+b*b-2*a*b*cos(c*PI/180))+a+b);
  printf("%.5f\n",b*sin(c*PI/180));
  return 0;
}


Measured memory_bytes: 3380
import sys

input = lambda: sys.stdin.readline().rstrip()


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

    count = 0
    for i in range(N - 2):
        if S[i:i + 3] == 'ABC':
            count += 1
    print(count)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, m;
int vis[N], dist[N], ways[N], ans[N];
vector<int> g[N];

void bfs(int k)
{
	queue<int> q;
	q.push(k);
	vis[k] = 1;
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		for(auto it:g[node])
		{
			if(!vis[it])
			{
				dist[it] = dist[node] + 1;
				vis[it] = 1;
				ans[it] = node;
				q.push(it);
			}
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(!vis[i])
		{
			cout << "No";
			exit(0);
		}
	}
}


int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bfs(1);
	cout << "Yes" << endl;
	for(int i = 2; i <= n; i++)
		cout << ans[i] << endl;
	return 0;
}


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

int main()
{
        ll H, W; cin >> H >> W;
        vector<vector<ll>> v(H, vector<ll>(W, 0));
        rep(i,H) {
                string s; cin >> s;
                rep(j,W) {
                        if (s[j] == '#') {
                                v[i][j] = 1;
                        }
                }
        }
        ll prev_r = -1;
        ll cur_l = 0;
        rep(i,H) {
                ll r = -1;
                ll l = -1;
                rep(j,W) {
                        if (v[i][j] == 1) {
                                r = j;
                                if (l == -1) {
                                        l = j;
                                }
                        }
                }
                if (prev_r != -1) {
                        if (l != prev_r) {
                                cout << "Impossible" << endl;
                                exit(0);
                        }
                }
                prev_r = r;
        }
        cout << "Possible" << endl;



}


Measured memory_bytes: 3576
n = 5
t = [int(input()) for _ in range(n)]

last, min = 0, 9
for i in range(n):
    if t[i] % 10 < min:
        if t[i] % 10 == 0:
            continue
        last = i
        min = t[i] % 10

ans = 0
for i in range(n):
    if i == last:
        continue
    if t[i] % 10 == 0:
        diff = 0
    else:
        diff = 10 - t[i] % 10
    ans += t[i] + diff

ans += t[last]

print(ans)

Measured memory_bytes: 9140
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Read.ints();
        int sum = 0;
        for(int i = 0; i < a.Length; i++)
        {
            if (i == 0) { sum = Math.Abs(a[0]);continue; }
            sum += Math.Abs(a[i]-a[i-1]);
        }
        sum += Math.Abs(a[a.Length - 1]);
        int sumi = sum;
        for (int i = 0; i < n; i++)
        {
            sum = sumi;
            if (i == 0) { if ((a[i + 1] - a[i]) * (a[i]) < 0) sum -= Math.Abs(a[i]) + Math.Abs(a[i + 1] - a[i]) - (Math.Abs(a[i + 1])); Console.WriteLine(sum); continue; }

            if (i == a.Length - 1)
            {
                if ((a[i] - a[i - 1]) * (a[i]) > 0)
                {
                    sum -= Math.Abs(a[i]-a[i-1]) + Math.Abs(a[i]) - (Math.Abs(a[i-1]));
                }
                Console.WriteLine(sum);
                continue;
            }
            int come = a[i] - a[i - 1];
            int go = a[i + 1] - a[i];
            if (come * go < 0) { sum -= Math.Abs(come)+Math.Abs(go)-(Math.Abs(a[i+1]-a[i-1])) ; }

            Console.WriteLine(sum);
        }
        Console.ReadLine();

    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static string Reverse(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 28124
n = int(input())
ans = n
for i in range(n+1):
    count = 0
    num = i
    while num > 0:
        count += num % 6
        num //= 6
    num = n - i
    while num > 0:
        count += num % 9
        num //= 9
    ans = min(ans, count)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') cout << 'A';
    else cout << 'a';
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m, p, x, sum = 0;
    cin >> n;
    vector<int> v(n);
    fore(i,0,n) {
        cin >> v[i];
        sum += v[i];
    }
    cin >> m;
    while (m--) {
        cin >> p >> x;
        cout << sum-v[p-1]+x << endl;
    }
}


Measured memory_bytes: 256