akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,min,s,co,count=0;
    char a;
    vector<int> v,v1,v2;
    vector<char> c,c1,c2;
    cin >> n;
    getchar();
    for(int i=0;i<n;i++){
        cin >> a >> s;
        v.push_back(s);
        c.push_back(a);
        v1.push_back(s);
        c1.push_back(a);
        v2.push_back(s);
        c2.push_back(a);
    }
    
    
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(v1[j]<v1[j-1]){
                swap(v1[j],v1[j-1]);
                swap(c1[j],c1[j-1]);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << c1[i]<<v1[i] << ((i==n-1)?"":" ") ;
    }
    cout<<endl<<"Stable"<<endl;
    
    
    
    for(int i=0;i<n;i++){
        min=i;
        for(int j=i+1;j<n;j++){
            if(v2[j]<v2[min]){
                min=j;
            }
        }
        swap(v2[i],v2[min]);
        swap(c2[i],c2[min]);
    }
    for(int i=0;i<n;i++){
        cout <<  c2[i]<< v2[i] << ((i==n-1)?"":" ") ;
    }
    for(int i=1;i<n;i++){
       if(v2[i]==v2[i-1]){
            count++;
            co=0;
            for(int j=0;j<n;j++){
                if(v[j]==v2[i]){
                    co++;
                    if(co-1==count&&c[j]!=c2[i]){
                    cout<<endl<<"Not stable"<<endl;
                    return 0;
                    }
                }
            }
        }
       else{
           count=0;
       }
    }
    cout<<endl<<"Stable"<<endl;
}

Measured memory_bytes: 3132
num = int(input())

Slist = [False] * 13
Hlist = [False] * 13
Clist = [False] * 13
Dlist = [False] * 13

for i in range(num):
    l = input().split()
    suit = l[0]
    num = int(l[1]) - 1

    if   suit == 'S':
        Slist[num] = True
    elif suit == 'H':
        Hlist[num] = True
    elif suit == 'C':
        Clist[num] = True
    elif suit == 'D':
        Dlist[num] = True

for i,exists in enumerate(Slist):
    if not exists:
        print(f'S {i+1}')

for i,exists in enumerate(Hlist):
    if not exists:
        print(f'H {i+1}')

for i,exists in enumerate(Clist):
    if not exists:
        print(f'C {i+1}')

for i,exists in enumerate(Dlist):
    if not exists:
        print(f'D {i+1}')


Measured memory_bytes: 5624
n = int(input())
dp = [[0 for _ in range(3)] for _ in range(n)]

dp[0][0],dp[0][1],dp[0][2] = map(int,input().split())

for i in range(1,n):
    abc = map(int,input().split())
    for j,v in enumerate(abc):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j],dp[i-1][k] + v)

print(max(dp[n-1]))


Measured memory_bytes: 24352
N = gets.to_i
s_list = N.times.map { gets.chomp.chars }
table = Hash.new { 0 }
s_list.each do |s|
  t = Hash.new { 0 }
  s.each do |ch|
    t[ch] += 1
  end
  if table.empty?
    table.merge!(t)
  else
    t.each do |ch, c|
      if table[ch]
        table[ch] = [table[ch], c].min
      end
    end
    table.each do |ch, _|
      table.delete(ch) unless t.key?(ch)
    end
  end
end
ans = table.flat_map do |ch, c|
  ch * c
end.sort.join('')
puts ans


Measured memory_bytes: 2044
def main():
    x,y = list(map(int, input().split()))

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = 0
    for i in range(1, 200):
        if i not in nums:
            ans = ans if abs(ans-x) <= abs(i-x) else i
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,variable-expansion-in-unroller")
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=40;
int n;
char s[N];

using P=tuple<int,int,string,string>;
map<P,LL> dp;

LL go( int l, int r, string sl, string sr ) {
    if ( r-l+1<SZ(sl)+SZ(sr) ) return 0;
    if ( l>r ) return sl.empty() && sr.empty();
    auto k=make_tuple(l,r,sl,sr);
    if ( dp.count(k) ) return dp[k];
    if ( !sl.empty() && s[r]!=sl[0] ) return dp[k]=go(l,r-1,sl,sr+s[r]);
    if ( !sr.empty() && s[l]!=sr[0] ) return dp[k]=go(l+1,r,sl+s[l],sr);
    LL ans=0;
    if ( !sl.empty() ) {
        assert(s[r]==sl[0]);
        ans+=go(l,r-1,sl.substr(1),sr);
        ans+=go(l,r-1,sl,sr+s[r]);
    } else if ( !sr.empty() ) {
        assert(s[l]==sr[0]);
        ans+=go(l+1,r,sl,sr.substr(1));
        ans+=go(l+1,r,sl+s[l],sr);
    } else {
        ans+=2*go(l+1,r,sl+s[l],sr);
    }
    return dp[k]=ans;
}

void main() {
    R(n,s);
    auto ans=go(0,2*n-1,"","");
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    vvec x(3,vec (n));
    rep(i,n){
        rep(j,3){
            int a;cin>>a;
            x[j][i]=a;
        }
    }

    for(int i = 0; i < (1 << n); i++) // bit全探索(2^n)
    {
        for(int j = 0; j < n; j++) // bitごとにみる(n)
        {
            if ((i >> j & 1)) // 左からj番目のbitが立っているとき
            {
                
            }
        }
    }
    ll ans=0;
    rep(i,(1<<3)){
        vec sum(n);
        int memo=0;
        rep(j,3){
            rep(k,n){
                if((i>>j)&1){
                    sum[k]-=x[j][k];
                }
                else{
                    sum[k]+=x[j][k];
                }
            }
        }
        sort(rall(sum));
        rep(k,m){
            memo+=sum[k];
        }
        chmax(ans,memo);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################
import sys
input=sys.stdin.readline
n ,q = I0()
counter = [0]*n
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b=I0()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for i in range(q):
    p,x = I0()
    counter[p-1]+=x
    
stack = [0]
seen = dict()
seen[0] = 1
while stack:
    yy = stack.pop()
    for i in tree[yy]:
        if seen.get(i,-1) == -1:
            seen[i] = 1
            counter[i]+=counter[yy]
            stack.append(i)
            
print(*counter)



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

int main()
{
	int tmp = 0;
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	while (true) {
		if (s[tmp].empty()) {
			break;
		}
		else {
			char t = s[tmp].front();
			s[tmp].erase(s[tmp].begin(), s[tmp].begin() + 1);
			tmp = (int)t - 'a';
		}
	}
	cout << (char)(tmp + 'A') << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
s=input()
n=len(s)
ks={'eam':'dream','mer':'dreamer','ase':'erase','ser':'eraser'}
while n > 0:
    if n < 3:
        break
    e=s[n-3:n]
    if e not in ks:
        break
    if n < len(ks[e]):
        break
    if s[n-len(ks[e]):n] != ks[e]:
        break
    n-=len(ks[e])
else:
    print('YES')
    sys.exit()
print('NO')

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

string a,b,c;


int main(){
	cin>>a>>b>>c;
	char Start = 'a';
	int Posa = 0;
	int Posb = 0;
	int Posc = 0;
	while(1){
		if(Start == 'a'){
			if(Posa >= a.length()) break;
			else Start = a[Posa];
			Posa++;
		} 
		else if(Start == 'b'){
			if(Posb >= b.length()) break;
			else Start = b[Posb];
			Posb++;
		}
		else if(Start == 'c'){
			if(Posc >= c.length()) break;
			else Start = c[Posc];
			Posc++;
		}
	}	
	if(Start == 'a') cout<<'A'<<endl;
	else if(Start == 'b') cout<<'B'<<endl;
	else cout<<'C'<<endl;
	return 0;
}

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


struct unionfind{ //構造体の定義
    vector<int> d; //メンバ変数
    unionfind(int n=0): d(n,-1) {} //コンストラクタ（構造体が呼ばれたときにすぐに実行される処理）
    int find(int x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return false;
        if(d[x]<d[y]) swap(x,y);//d[x] is smaller. Then, connect d[x] to d[y].
        d[y]+=d[x];
        d[x]=y;
        return true;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -(d[find(x)]);   
    }
};


int main(){
    int n,m,k;
    cin>>n>>m>>k;
    int fr[100005];
    vector<int> bl[100005];
    unionfind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a; --b;
        fr[a]++; fr[b]++;
        uf.unite(a,b);
    }
    rep(i,k){
        int a,b;
        cin>>a>>b;
        --a; --b;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }
    rep(i,n){
        int ans;
        ans=uf.size(i)-1-fr[i];
        for(int a : bl[i]){
            if(uf.same(i,a)) ans--;
        }
        cout<<ans<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const long long mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    int m; cin >> m;
    vector<int> b(m);
    for(int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        b[i] = tmp;
    }
    for(int i = 0; i < m; i++){
        if(!binary_search(a.begin(),a.end(),b[i])){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 4324
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007
#define PI 3.14159265
#define seive_len 1

typedef long long int lli;

int *array;
int seive[seive_len];

long long int min(long long int a, long long int b) {
    return a<b?a:b;
}

long long int max(long long int a, long long int b) {
    return a>b?a:b;
}

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

int cmp(const void *a, const void *b){
    int ia = *(int *)a;
    int ib = *(int *)b;
    return array[ia] < array[ib] ? -1 : array[ia] > array[ib];
}

long double abs1(long double n) {
    if(n < 0)
        return n*(-1.0);
    return n*1.0;
}

void swap(int *a, int *b) {
    *a = (*a)^(*b);
    *b = (*a)^(*b);
    *a = (*a)^(*b);
}

lli binSearch(lli a[], lli x, lli l, lli r) {
    if(r >= l) {
        lli mid = l + ((r-l)>>1);
        if(a[mid] == x)
            return mid;
        if(a[mid] > x) {
            return binSearch(a, x, l, mid-1);
        }
        else if(a[mid] < x) {
            return binSearch(a, x, mid+1, r);
        }
    }
    return -1;
}

void makeSeive() {
    int i;
	seive[1] = 1;
    for(i=2;i<seive_len;i++) {
        if(seive[i] == 0) {
            long long int temp=(long long int)i*i;
            while(temp <= seive_len-1) {
                seive[temp] = 1;
                temp += i;
            }
        }
    }
}

int isPrime(int n) {
    int i;
    for(i=2;i*i<=n;i++)  {
        if(n%i == 0)
            return 0;
    }
    return 1;
}

void getInput(lli a[], lli n) {
    for(lli i=0;i<n;i++)
        scanf("%lld", &a[i]);
}

int titleToNumber(char* s)
{
    int sum = 0;
    while(*s) sum = 26*sum+(*(s++)-'A'+1);
    return sum;
}

void testCase() {
    lli n, i, k;
    scanf("%lld", &n);
    lli a[n];
    getInput(a, n);
    lli x = 0;
    for(i=0;i<n;i++) {
        x ^= a[i];;
    }
    for(i=0;i<n;i++) {
        lli ans = x^a[i];
        printf("%lld ", ans);
    }

}

int main() {
    int t=1;
    // scanf("%d", &t);
    // makeSeive();
    while(t--) {
        testCase();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MinimizeAbsoluteDifferenceDiv1
{
    public:
vector <int> findTuple(vector <int> x)
{


}
};
int main()
{
    LL a,b;
    while(cin>>a>>b){
        LL w[100005]={};
        LL w1[100005]={};
        LL w2[100005]={};
        LL x[100005]={};
        for(int i=1;i<=a;i++){
            cin>>x[i]>>w[i];
        }
        for(int i=1;i<=a;i++)
            w[i]=w[i-1]+w[i];

        LL t1[100005]={};
        LL t2[100005]={};
        LL ans=0;
        for(int i=1;i<=a;i++){
            w1[i]=w[i]-x[i];
            w2[i]=w[a]-w[i-1]-(b-x[i]);
            t1[i]=w1[i]-x[i];

            t2[i]=w2[i]-(b-x[i]);

            ans=max(ans,w1[i]);
            ans=max(ans,w2[i]);
        }
        LL num=0;
        for(int i=1;i<=a;i++){
            ans=max(ans,num+w2[i]);
            num=max(num,t1[i]);
        }
        num=0;
        for(int i=a;i>=1;i--){
                   ans=max(ans,num+w1[i]);
            num=max(num,t2[i]);

        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4992
let pi = 4. *. atan 1.

let to_radian degree = pi *. degree /. 180.

type point = { x : float; y : float }

let print_point e = Printf.printf "%f %f\n" e.x e.y

let rec koch n a b =
  if n > 0 then begin
    let s =
      let x = (2. *. a.x +. b.x) /. 3. in
      let y = (2. *. a.y +. b.y) /. 3. in
      { x; y } in
    let t =
      let x = (a.x +. 2. *. b.x) /. 3. in
      let y = (a.y +. 2. *. b.y) /. 3. in
      { x; y } in
    let u =
      let x = (t.x -. s.x) *. cos (to_radian 60.) -. (t.y -. s.y) *. sin (to_radian 60.) +. s.x in
      let y = (t.x -. s.x) *. sin (to_radian 60.) +. (t.y -. s.y) *. cos (to_radian 60.) +. s.y in
      { x; y } in
    koch (n - 1) a s;
    print_point s;
    koch (n - 1) s u;
    print_point u;
    koch (n - 1) u t;
    print_point t;
    koch (n - 1) t b
  end

let () =
  let n = read_int () in
  let p1 = { x = 0.; y = 0. } in
  let p2 = { x = 100.; y = 0. } in
  print_point p1;
  koch n p1 p2;
  print_point p2

Measured memory_bytes: 4640
N, K, C = map(int, input().split())
S = list(input())

# 左詰めの働くリスト
l_list = [-1 for i in range(N)]
i = 0
cnt = 0
while(i < N and cnt < K):
	if(S[i] == "o"):
		l_list[i] = cnt
		cnt += 1
		i += C
	i += 1

# 右詰めの働くリスト
r_list = [-1 for i in range(N)]
i = N - 1
cnt = 0
while(i >= 0 and cnt < K):
	if(S[i] == "o"):
		r_list[i] = K-1-cnt
		cnt += 1
		i -= C
	i -= 1

# 両方のリストで一致するマス(日)を出力
for i in range(N):
	if(l_list[i] == -1 or r_list[i] == -1):
		continue
	if(l_list[i] == r_list[i]):
		print(i+1)


Measured memory_bytes: 22008
(defn abs [x]
  (if (neg? x)
    (- x)
    x))

(-> (loop [lines (map #(clojure.string/split % #"\s")
                      (rest (line-seq (clojure.java.io/reader *in*))))
           [curr-t curr-x curr-y] [0 0 0]]
      (if-let [line (first lines)]
        (let [[t x y :as next-dest] (map #(Integer/parseInt %) line)
              d-t (- t curr-t)
              d-x (abs (- x curr-x))
              d-y (abs (- y curr-y))
              d-x+y (+ d-x d-y)]
          (if (zero? (mod d-t d-x+y))
            (recur (rest lines) next-dest)
            false))
        true))
    (if "Yes" "No")
    println)


Measured memory_bytes: 117428
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int  a, b, c;
    cin >> a >> b >> c;
    if(a+b >= c){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;
const int infty = 1<<28;

struct Node{
  vector<int> con;
  vector<int> in;
  vector<int> cost;
};

typedef vector<Node> Graph;

double topologicalSort(const Graph &G, int n, int s, int g)
{
  double numPath[n];
  int invis[n];
  bool vis[n];
  queue<int> q;
  for(int i = 0; i < n; ++i){
    invis[i] = 0;
    numPath[i] = 0.0;
    vis[i] = false;
  }
  numPath[s]=1.0;
  
  q.push(s);
  vis[s]=true;
  while(!q.empty()){
    int now = q.front();
    q.pop();
    
    for(int i = 0; i < G[now].con.size(); ++i){
      int nid = G[now].con[i];
      invis[nid]++;
      numPath[nid] += numPath[now];
      if( invis[nid] == G[nid].in.size() ){
	if( !vis[nid] ){
	  vis[nid]=true;
	  q.push( nid );
	}
      }
    }
  }
  
  return numPath[g];
}

int main()
{
  while(true){
    int n,m,p;
    cin >> n >> m >> p;
    if( n == 0 && m == 0 && p == 0 ) break;
    int c[p];
    double cPath[n];
    Graph G(n);
    Graph DAG(n);
    Graph rDAG(n);
    int d[n][n];
    
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	if( i == j ) d[i][j] = 0;
	else d[i][j] = infty;
      }
    }

    for(int i = 0; i < m; ++i){
      int a,b,c;
      cin >> a >> b >> c;
      G[a].con.push_back(b);
      G[a].cost.push_back(c);
      G[b].con.push_back(a);
      G[b].cost.push_back(c);
      d[a][b]=min(d[a][b],c);
      d[b][a]=min(d[b][a],c);
    }
    for(int i = 0; i < p; ++i){
      cin >> c[i];
    }
    
    for(int k = 0; k < n; ++k){
      for(int i = 0; i < n; ++i){
	for(int j = 0; j < n; ++j){
	  d[i][j] = min( d[i][j], d[i][k]+d[k][j] );
	}
      }
    }
    
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < G[i].con.size(); ++j){
	int u = i;
	int v = G[i].con[j];
	int w = G[i].cost[j];
	if( d[0][u]+w+d[v][n-1] == d[0][n-1] ){
	  DAG[u].con.push_back(v);
	  rDAG[v].con.push_back(u);
	  DAG[v].in.push_back(u);
	  rDAG[u].in.push_back(v);
	}
      }
    }

    double sgPath = topologicalSort( DAG, n, 0, n-1 );
    for(int i = 0; i < p; ++i){
      cPath[i] = topologicalSort( DAG, n, 0, c[i] );
      //cout << cPath[i] << ' ';
      cPath[i] *= topologicalSort( rDAG, n, n-1, c[i] );
      //cout << cPath[i] << endl;
      printf("%.12lf\n", cPath[i]/sgPath );
    }
    putchar('\n');
    
  }
  return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
#define rep(i, n) fpr(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int half = n / 2;
  string hs = s.substr(0, half);
  if (hs + hs == s) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double x[n];
    string u[n];
    long long a=0;
    long double b=0;
    for(int  i=0; i<n; i++){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY"){
            a+=x[i];
        }
        else{
            b+=x[i];
        }
    }
    double ans=a+380000*b;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  string s;
  cin >> s;
  string res;
  for(char c : s){
    if(c == 'B'){
      if(not res.empty()) res.pop_back();
    }else{
      res += c;
    }
  }
  cout << res << endl;
}


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

int main()
{
    vector<ll> A(5);
    ll k;
    cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4] >> k;

    for(ll i = 0; i < 4; i++)
    {
        for(ll j = i+1; j < 5; j++)
        {
            if(A[j] - A[i] > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>):Unit {
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val (tag, _) = parseTagStructure(readLine()!!.trim())
        repeat(n){
            val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
            val t = tag.touchedTag(Point(x, y))
            println(
                    when(t){
                        null -> "OUT OF MAIN PANEL 1"
                        else -> "${t.name} ${t.childSize()}"
                    }
            )
        }
    }
}
class Tag(val name:String, val leftTop:Point, val rightBottom:Point, private val mChildren: Iterable<Tag>){
    private fun isTouched(touchPoint:Point):Boolean {
        return touchPoint.x in leftTop.x .. rightBottom.x && touchPoint.y in leftTop.y .. rightBottom.y
    }
    fun childSize():Int = mChildren.count()
    fun touchedTag(touchPoint:Point):Tag? {
        return if (isTouched(touchPoint)){
            val child = mChildren.mapNotNull{it.touchedTag(touchPoint)}.firstOrNull()
            when(child){
                null -> this
                else -> child
            }
        }else null
    }
}
fun parsePoints(str:String):Pair<Pair<Point, Point>, String> {
    val pattern = """^(\d+),(\d+),(\d+),(\d+)(.*)""".toRegex()
    val matched = pattern.matchEntire(str)!!
    val (a, b, c, d) = matched.groupValues.drop(1).take(4).map(String::toInt)
    val rest = matched.groupValues.last()
    return Pair(Pair(Point(a, b), Point(c, d)), rest)
}
fun parseStartTag(str:String):Pair<String, String> {
    val pattern = """^<(\w+)>(.*)""".toRegex()
    val matched = pattern.matchEntire(str)!!
    return Pair(matched.groupValues[1], matched.groupValues[2])
}
fun parseEndTag(str:String):Pair<String, String>{
    val pattern = """^</(\w+)>(.*)""".toRegex()
    val matched = pattern.matchEntire(str)!!
    return Pair(matched.groupValues[1], matched.groupValues[2])
}
fun parseTagStructure(str:String):Pair<Tag, String>{
    val (name, rest) = parseStartTag(str)
    val (p, rest2) = parsePoints(rest)
    val (tags, rest3) = parseTagSequence(rest2)
    val (endName, r) = parseEndTag(rest3)
    assert(name == endName)
    return Pair(Tag(name, p.first, p.second, tags), r)
}
fun parseTagSequence(str:String):Pair<Collection<Tag>, String> {
    val stack = Stack<Tag>()
    val startTag = """^<(\w+)>(.*)""".toRegex()
    var s = str
    while(true){
        if (startTag.matches(s)){
            val (t, r) = parseTagStructure(s)
            stack.push(t)
            s = r
        }else return Pair(stack, s)
    }
}
data class Point(val x:Int, val y:Int)


Measured memory_bytes: 33224
#include<bits/stdc++.h>
#define MAXN 100010
#define pb push_back
#define mt make_tuple
using namespace std;

int d,col[MAXN],mx[MAXN];
bool vis[MAXN][20];
vector<int>adj[MAXN];
vector<tuple<int,int,int>>vec;
vector<tuple<int,int,int>>::reverse_iterator it;

void dfs(int node,int cl,int dist){
	if(!col[node])
		col[node]=cl;
	for(int i=0;i<adj[node].size();i++){
		int child=adj[node][i];
		if(mx[child]<dist-1){
			mx[child]=dist-1;
			dfs(child,cl,dist-1);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int n,m,u,v,c;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int qr;
	cin>>qr;
	for(int i=0;i<qr;i++){
		cin>>v>>d>>c;
		vec.pb(mt(v,d,c));
	}
	fill(mx,mx+MAXN,-1);
	for(it=vec.rbegin();it!=vec.rend();it++){
		d=get<1>(*it);	v=get<0>(*it);	c=get<2>(*it);
	//	dfs(get<0>(*it),0,get<2>(*it),-1);
		if(d>mx[v]){
			mx[v]=d;
			dfs(v,c,d);
		}
	}
	for(int i=1;i<=n;i++){
		cout<<col[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 10608
import sys
input = sys.stdin.readline

N, A, B = list(map(int, input().split()))
C = A-B
H = [int(input()) for _ in range(N)]

def check(K):
  s = 0
  D = K*B
  for h in H: s += max(0, (h-D+C-1)//C)
  return s<=K

max_NG = 0
min_OK = 10**10
while min_OK - max_NG > 1:
  tgt = (max_NG+min_OK)//2
  if check(tgt):
    min_OK = tgt
  else:
    max_NG = tgt

print(min_OK)

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

// @@ !! LIM(sieve)
// --> sieve
// ---- inserted library file sieve.cc

// sieve(upto) returns the list of prime numbers up to upto.
//   Size: upto(1e8).size() ... 5.7e6,  upto(1e9).size() ... 5.1e7
//   Performance: upto(1e8) ... 0.7sec,   upto(1e9) ... 9.2sec
vector<int> sieve(int upto) {
  vector<int> res;
  vector<bool> tbl(upto+1);
  ll lim = (int)(sqrt((double)upto)) + 1;
  for (int x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (int y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

/*
  Prime Factorization
    Two versions:
      - prfac(n)
      - prfac(n, primes)
 */

vector<pair<ll, int>> prfac(ll n, const vector<int>& primes) {
  //      primes should contain prime numbers at least up to sqrt(n)
  vector<pair<ll, int>> res;
  ll x = n;
  for (ll p : primes) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    int c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

vector<pair<ll, int>> prfac(ll n) {
  return prfac(n, sieve((int)(sqrt((double)n)) + 1));
}

/*
    List of divisors
      - getDivisors(n)
    Note: the results are NOT sorted
 */

// gdsub ... aux function used in getDivisors()
vector<ll> gdsub(int i, int n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll p  = fs.at(i).first;
  int r = fs.at(i).second;
  ll pp = p;    // pp = p^m, for m \in [1, r]
  int partOrigLen = part.size();
  for (int m = 1; m <= r; m++) {
    for (int j = 0; j < partOrigLen; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n) {
  auto fs = prfac(n);
  return gdsub(0, fs.size(), fs);
}

// ---- end sieve.cc
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  auto divs = getDivisors(M);
  sort(divs.begin(), divs.end(), greater<ll>());
  for (ll r : divs) {
    ll k = M / r;
    if (k >= N) {
      cout << r << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1e9+7;

signed main(){
  
  cout << fixed << setprecision(15);
  double PI = 3.1415926535897932;
  
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double chou = M*6;
  double tan = (H*60+M)*0.5;
  double kakudo = abs(chou-tan);
  if( kakudo == 0 ){
    cout << abs(A-B) << endl;
    return 0;
  }
  // if( kakudo > 180 ) kakudo -= 180;
  kakudo = min(kakudo, 360 - kakudo);
  double Ck = cos(PI*kakudo/180);
  double C = A*A +B*B -2*A*B*Ck;
  cout << sqrt(C) << endl;
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector <ll> v;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            int ctr=0;
            int check=0;
            ll val1=0;
            for(int i=0;i<s.length();i++){
                if(s[i]!='.'){
                    val1=val1*10+(s[i]-'0');
                    if(check==1)
                        ctr++;
                }
                else
                    check=1;
            }
            ll val=power(10ll,9ll-ctr);
            val1*=val;
            v.push_back(val1);
        }
        ll ctr[19][19];
        for(int i=0;i<19;i++){
            for(int j=0;j<19;j++){
                ctr[i][j]=0ll;
            }
        }
        ll ans=0;
        for(int i=0;i<v.size();i++){
            int c1,c2;
            c1=0;c2=0;
            while(v[i]%5==0){
                v[i]/=5;
                c1++;
            }
            while(v[i]%2==0){
                v[i]/=2;
                c2++;
            }
            ctr[min(c1,18)][min(c2,18)]++;
        }
        for(int i=0;i<=18;i++){
            for(int j=0;j<=18;j++){
                for(int k=0;k<=18;k++){
                    for(int l=0;l<=18;l++){
                        if(i+k>=18&&j+l>=18){
                            if(k>i||(k==i&&j>l))
                                ans+=ctr[i][j]*ctr[k][l];
                            else if(k==i&&j==l)
                                ans+=(ctr[i][j]*(ctr[i][j]-1))/2;
                        }
                    }
                }
            }
        }
        cout<<ans<<"\n";
    }
    return 0ll;
}


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

int main(){
  int n, k;
  std::cin >> n >> k;
  std::vector<int> v(n);
  int64_t ans = 0;
  
  for (int i = 0; i < n; i++) {
    std::cin >> v.at(i);
  }
  sort(v.begin(), v.end());

  for (int i = 0; i < k; i++) {
    v.pop_back();
  }
  for (int i = 0; i < n-k; i++) {
    ans += v.at(i);
  }
  std::cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func kaibun(s string) bool {
	i := 0
	j := len(s) - 1
	for i < len(s)/2 {
		if s[i] != s[j] {
			return false
		}
		i = i + 1
		j = j - 1
	}

	return true
}

func check(s string) bool {
	if len(s)%2 == 0 {
		if kaibun(s[:len(s)/2]) == false || kaibun(s[len(s)/2:]) == false {
			return false
		}
	} else {
		if kaibun(s[:len(s)/2]) == false || kaibun(s[len(s)/2+1:]) == false {
			return false
		}
	}
	return true
}

func kosuu(n int) int {
	return n * (n - 1) / 2
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	C := make([]int, N+1)
	A := make([]int, N)
	M := make(map[int]int, 0)
	for i := 0; i < N; i++ {
		A[i] = sc.nextInt()
		C[A[i]]++
		M[A[i]] = -1
	}

	total := 0
	for k := range M {
		total += kosuu(C[k])
	}

	for k := 0; k < N; k++ {
		fmt.Println(total - C[A[k]] + 1)
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 16384
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

#include <iostream>

using namespace std;

void scans(string & str) {
	char c;
	scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int n;
	scanf("%d", &n);
	ll ans = 0;
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	rep(i, n) {
		for (int j = i + 1; j < n; ++j) {
			ans += a[i] * a[j];
		}
	}
	printf("%lld\n", ans);

 	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using lint=int64_t;
using namespace std;

const int dh[]={0,-1,0,1};
const int dw[]={1,0,-1,0};

using Info=pair<int,pair<int,int>>;
Info makeInfo(int d,int h,int w)
{
	return make_pair(d,make_pair(h,w));
}

int main()
{
	int H,W;
	string A[1010];

	cin >> H >> W;
	for(int i=0;i<H;i++)
		cin >> A[i];
	
	int dist[1010][1010]={};
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			dist[i][j]=-1;

	queue<Info> que;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(A[i][j]=='#')
			{
				dist[i][j]=0;
				que.push(makeInfo(0,i,j));
			}
		}
	}
	
	while(!que.empty())
	{
		int cd=que.front().first;
		int ch=que.front().second.first;
		int cw=que.front().second.second;
		que.pop();

		for(int i=0;i<4;i++)
		{
			int nh=ch+dh[i];
			int nw=cw+dw[i];

			if(nh<0 || nw<0 || nh>=H || nw>=W)continue;
			if(dist[nh][nw]!=-1)continue;

			dist[nh][nw]=cd+1;
			que.push(makeInfo(cd+1,nh,nw));
		}
	}

	int ans=0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			ans=max(ans,dist[i][j]);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17424
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int x;
    cin >> x;
    YESNO(x < 1200, "ABC", "ARC");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
ll d[100005];
int c[100005];
int vis[100005];
vector<pii> g[100005];
void dfs(int u) {
  vis[u] = 1;
  for (pii q : g[u]) {
    ll v = q.ff, w = q.ss;
    if (vis[v])
      continue;
    d[v] = d[u] + w;
    if (d[v] & 1)
      c[v] = 1;
    else
      c[v] = 0;
    dfs(v);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    g[u].pb({v, w});
    g[v].pb({u, w});
  }
  dfs(1);
  for (int i = 1; i <= n; i++)
    cout << c[i] << endl;
}

Measured memory_bytes: 10112
using namespace std;
typedef long long ll;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
 
int main(){
    int N;
    cin >> N;
    vector<ll> ans;
    while (N!=0)
    {
        vector<ll> a;
        a.resize(N);
        for (int i = 0; i < N; i++) cin >> a[i];
        ll thismin = 1e10;
        for (int i = 0; i < N;i++) {
            for (int n = 0; n < N; n++) {
                if (n == i) continue;
                thismin = min(thismin, abs(a[i] - a[n]));
            }
        }
        ans.push_back(thismin);
        cin >> N;
    }
    for (int i = 0; i < ans.size();i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int dp[n];
    for(int i=0;i<n;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if((i-j)>=0)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
    }
    cout << dp[n-1];
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n, m;
  cin >> n >> m;
  vl a(n), b(n), c(m), d(m);
  re(i, n) cin >> a[i] >> b[i];
  re(j, m) cin >> c[j] >> d[j];

  re(i, n) {
    ll min = inf;
    int k = 0;
    re(j, m) {
      ll s = llabs(a[i] - c[j]) + llabs(b[i] - d[j]);
      if(s < min) {
        min = s;
        k = j + 1;
      }
    }
    cout << k << endl;
  }

  return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	int N;
	int cnt[255]={};

	cin >> N;
	rep(i,N){
		string S;
		cin >> S;
		if(i==0){
			for(auto t: S){
				cnt[t]++;
			}
		}else{
			int sum[255]={};
			for(auto t: S) sum[t]++;
			rep(j,255) chmin( cnt[j], sum[j] );
		}
	}

	string ans;
	for(auto t='a'; t<='z'; t++){
		ans += string(cnt[t], t);
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m, q;
    static vector<int> edges[100000];
    static tuple<int, int, int> queries[100001];
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    cin >> q;
    for(int i=1;i<=q;++i){
        int v, d, c;
        cin >> v >> d >> c;
        queries[i] = tuple<int, int, int>{v-1, d, c};
    }

    static int dp[100000][11];
    for(int t=q;t>0;--t){
        int v, d;
        tie(v, d, ignore) = queries[t];
        dp[v][d] = max(dp[v][d], t);
    }
    for(int d=10;d>0;--d){
        for(int v=0;v<n;++v){
            if(dp[v][d] == 0) continue;
            dp[v][d-1] = max(dp[v][d-1], dp[v][d]);
            for(int u: edges[v]) dp[u][d-1] = max(dp[u][d-1], dp[v][d]);
        }
    }
    for(int v=0;v<n;++v) cout << get<2>(queries[dp[v][0]]) << endl;
    
    return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int>adj[n+1];
    for(int i = 0;i <m;i++){
        int a,b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<bool>vis(n+1);
    vis[1] = true;
    queue<int>qu;
    qu.push(1);
    vector<int>ans(n+1);
    while(!qu.empty()){
        int ac = qu.front();
        qu.pop();
        for(int i: adj[ac]){
            if(!vis[i]){
                vis[i] = true;
                ans[i] = ac;
                qu.push(i);
            }
        }
    }
    int cant = 0;
    for(int i = 1;i <= n;i++){
        cant += vis[i];
    }
    if(cant == n){
        cout << "Yes" << endl;
        for(int i = 2;i <= n;i++){
            cout << ans[i] << endl;
        }
    }
    else{
        cout << "No";
    }
}



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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');
            long a = long.Parse(str[0]);
            long b = long.Parse(str[1]);


            int min = (int) a * 100 / 8;
            int max = (int)(a + 1) * 100 / 8;

            if (min < b * 10) { min = (int)b * 10; }
            if (max > (b + 1) * 10) { max = (int)(b + 1) * 10; }


            for(int i = min; i < max; i++)
            {
                int p8 = i * 8/100;
                int p10 = i  / 10;
                if (p8 == a && p10== b)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(-1);


            //ここまで
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S;
  cin>>S;
  cout<<S[0]<<S[1]<<S[2]<<S[3]<<" "<<S[4]<<S[5]<<S[6]<<S[7]<<S[8]<<S[9]<<S[10]<<S[11]<<endl;
return 0;}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int a,b,c;
  	cin >> a >> b >>c;
  	if (a==b){
      cout << c;
    }
  	else{
      if(a==c){
      	cout << b;
      }
      else{
      	cout << a;
      }
    }
  }


Measured memory_bytes: 256