akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    while(cin>>n){
        vl a(n); forn(i,n) cin>>a[i];

        ll tot = 0;
        ll mx = a[0];

        fore(i,1,n){
            tot+=max(0ll,mx-a[i]);
            max_self(mx, a[i]);
        }
        cout<<tot<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4788
N = int(input())
S = input()
abc = 'abcdefghijklmnopqrstuvwxyz'

ans = 0
for i in range(1,N):
    left = S[:i]
    righ = S[i:]
    tmp = 0
    for ch in abc:
        if ch in left and ch in righ:
            tmp += 1
    if tmp > ans:
        ans = tmp

print(ans)


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

#define int            long long 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

}

void solutionA()
{
	int n;
	cin>>n;

	if(n%1000==0)
	{
		cout<<"0"<<endl;
	}
	else
	{
		cout<<1000-(n%1000)<<endl;
	}
}

void solutionB()
{

}

void solutionC()
{

}

int32_t main()
{
	c_p_c();

	solutionA();
	//solutionB();
	//solutionC();

	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    REP(i, s.length()) {
        if (i%2 == 0) {
            if (s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

answer = 10**18
for c in range(10**6+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a, 0)*A
  cost += max(b, 0)*B
  if answer > cost:
    answer = cost
print(answer)


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  string s;
  char a,b;
  cin >> s;
  sort(s.begin(),s.end());
  if((s.at(0) == s.at(1)) && (s.at(2) == s.at(3)) && (s.at(0) != s.at(3))){ 
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n;
    cin>>n;
    ll ans = 0;
    REP(a,1,n) {
        if(n%a)
            ans += (n/a);
        else
            ans += (n/a-1);
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


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

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

    int N;
    double T, A;
    cin >> N >> T >> A;
    int ans = 0;
    double mindist = 1e5;
    for (int i = 1; i <= N; ++i) {
        double H;
        cin >> H;
        double _tmp = T - H * 0.006;
        if (abs(A - _tmp) < mindist) {
            ans = i;
            mindist = abs(A - _tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

template <typename T>
class Dijkstra {
    struct edge { int to; T cost; };
    typedef pair<T, int> P; // <最短距離, 頂点番号>

public:
    T INF;

    Dijkstra(int V) 
        : INF(std::numeric_limits<T>::max())
        , m_V(V)
        {
        m_G.resize(m_V);
    }

    // a -> bに片方向のエッジを張る
    void add_dir_edge(int a, int b, T cost) {
        m_G[a].push_back( edge{ b, cost } );
    }

    // a <-> bに両方向のエッジを張る
    void add_undir_edge(int a, int b, T cost) {
        add_dir_edge(a, b, cost);
        add_dir_edge(b, a, cost);
    }

    // 頂点sから各頂点までの距離を計算して返す
    vector<T> shortest_path(int s) {
        vector<T> d(m_V, INF);
        priority_queue<P, vector<P>, greater<P> > que;
        d[s] = 0;
        que.push(P(0, s));
    
        while(!que.empty()) {
            P p = que.top();
            que.pop();

            auto dist = p.first;
            auto v = p.second;
            if (d[v] < dist) continue;
            REP(i, m_G[v].size()) {
                edge e = m_G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }

        return d;
    }

private:
    int m_V;
    vector<vector<edge> > m_G;
};

int main(void)
{
    cin.sync_with_stdio(false);
    pair<ll,ll> s, e;
    cin >> s.first >> s.second >> e.first >> e.second;
    int N;
    cin >> N;
    vector<tuple<ll,ll,ll>> circles;
    REP(n,N) {
        ll x, y, r;
        cin >> x >> y >> r;
        circles.pb( mt(x,y,r) );
    }
    circles.pb( mt(s.first, s.second, 0) );
    circles.pb( mt(e.first, e.second, 0) );

    // start: N
    // end: N+1
    int size = SIZE(circles);
    Dijkstra<double> dij(size);
    REP(i, size-1) {
        const auto& c1 = circles[i];
        FOR(j, i+1, size) {
            const auto& c2 = circles[j];
            auto len1 = abs(get<0>(c1) - get<0>(c2));
            auto len2 = abs(get<1>(c1) - get<1>(c2));
            double dist = hypot(len1, len2);
            dist -= get<2>(c1) + get<2>(c2);
            dist = max(0.0, dist);
            //cout << "dist:" << dist << endl;
            dij.add_undir_edge(i, j, dist);
        }
    }
    auto shortests = dij.shortest_path(N);

    //for(auto e: shortests) {
    //    cout << e << ",";
    //}
    //cout << endl;

    printf("%.13lf\n", shortests[N + 1]);

    return 0;
}


Measured memory_bytes: 20756
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i=0;i<n;i++){
        if(i+1 != p[i]){
            count++;
        }
    }
    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int x,y,i;
    
    for(i=1;i<=3000;i++){
        scanf("%d",&x);
        scanf("%d",&y);
        if(x==0&&y==0){
            break;
        }else{
            if(x>y){
                printf("%d %d\n",y,x);
            }else{
                printf("%d %d\n",x,y);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2044
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    a, v = rl()
    b, w = rl()
    t = ri()
    d = abs(a - b)
    s = v - w
    if t * s >= d:
        print ("YES")
    else:
        print ("NO")





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 65192
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0)
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def print2(t)
		return if t==0
		print2(get_b(t))
		Kernel.print(' ')
		Kernel.print(get_a(t))
		@first=false
		print2(get_c(t))
	end
	def print3(t)
		return if t==0
		Kernel.print(' ')
		Kernel.print(get_a(t))
		@first=false
		print3(get_b(t))
		print3(get_c(t))
	end
	def print
		@first=true
		print2(root_triany)
		Kernel.puts
		@first=true
		print3(root_triany)
		Kernel.puts
	end
end

dicti=SETI.new
sum=0
gets.to_i.times{
	gets
	if $_[0..0]=='i'
		a=$_.split
		dicti.set_entry(a[1].to_i)
	elsif $_[0..0]=='f'
		a=$_.split
		puts dicti.find_entry(a[1].to_i) ? :yes : :no
	elsif $_[0..0]=='p'
		dicti.print
	end
}

Measured memory_bytes: 155500
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DColoringEdgesOnTree {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int N;
    vector<vector<P>> G;
    vector<int> color;

    void dfs(int v, int p, int n) {
        int c = 1;
        REP(i,G[v].size()) {
            int child, idx;
            tie(child, idx) = G[v][i];
            if (child == p) continue;

            if (c == n) c++;
            color[idx] = c;

            dfs(child, v, c);
            c++;
        }
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N;
        G.resize(N), color.resize(N - 1);
        REP(i, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back({b, i});
            G[b].push_back({a, i});
        }

        dfs(0, -1, 0);

        int res = -1;
        REP(i, color.size()) {
            res = max(res, color[i]);
        }
        cout << res << endl;
        REP(i, color.size()) {
            cout << color[i] << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DColoringEdgesOnTree solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 8704
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] is_prime = new boolean[1000001];
		Arrays.fill(is_prime, true);
		is_prime[0] = is_prime[1] = false;
		
		ArrayList<Integer> prime_list = new ArrayList<Integer>();
		
		for(int i = 2; i <= 1000; i++){
			if(is_prime[i]){
				for(int j = 2 * i; j <= 1000000; j += i){
					is_prime[j] = false;
				}
			}
		}
		
		for(int i = 0; i <= 1000000; i++){
			if(is_prime[i]){
				prime_list.add(i);
			}
		}
		
		//System.out.println(prime_list);
		
		while(true){
			final int n = sc.nextInt();
			
			
			if(n == 0){
				break;
			}
			
			int sum = 0;
			
			for(int i = 0; i < n; i++){
				final int p = sc.nextInt();
				final int m = sc.nextInt();
				
				int pre = Collections.binarySearch(prime_list, p - m);
				if(pre < 0){
					pre = -(pre + 1);
				}
				
				int post = Collections.binarySearch(prime_list, p + m);
				if(post < 0){
					post = (-(post + 1) - 1);
				}
				
				//if(pre > post){
				//	post = pre;
				//}
				
				if(pre > post){
					sum -= 1;
				}else if(pre < post){
					sum += post - pre;
				}else{
					sum += 0;
				}
				
				//System.out.println(pre + " " + post + " " + sum);
			}
			
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 15000
#include<iostream>

int main(void){
  int A, B;
  std::cin >> A >>B;
  if(A*B==2){
    std::cout << 3;
  }else if(A*B==6){
    std::cout << 1;    
  }else{
    std::cout << 2;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++) {
		if (i < A) {
			if (!('0' <= S[i] && S[i] <= '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
		else if(i == A) {
			if (S[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (!('0' <= S[i] && S[i] <= '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}





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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double a;
    while (cin >> a)
    {
        double be = a, sum = a;
        for (int i = 2; i <= 10; i++)
        {
            if (i % 2 == 0)
            {
                sum += be * 2;
                be *= 2;
            }
            else
            {
                sum += be / 3;
                be = be / 3;
            }
        }
        printf("%.8f\n", sum);
    }
    return 0;
}


Measured memory_bytes: 3128
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(w_max+1, 0)
items.each do |w, v|
  prev = dp.dup
  prev.each_with_index do |pv, pw|
    if pw+w <= w_max && prev[pw+w] < pv+v
      dp[pw+w] = pv+v
    end
  end
end
puts dp.last


Measured memory_bytes: 69004
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

int field[9][9];
const int p[] = {0, 3, 6};

char check(int y, int x)
{
  REPS(i, x, 9) if (x != i && field[y][x] == field[y][i]) return '*';
  REPS(i, y, 9) if (y != i && field[y][x] == field[i][x]) return '*';
  DEP(i, x) if (x != i && field[y][x] == field[y][i]) return '*';
  DEP(i, y) if (y != i && field[y][x] == field[i][x]) return '*';

  REPS(i, p[y / 3], p[y / 3] + 3){
    REPS(j, p[x / 3], p[x / 3] + 3){
      if (i == y && j == x) continue;
      if (field[y][x] == field[i][j]) return '*';
    }
  }

  return ' ';
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);

  while (n--){
    char table[9][9];
        
    REP(i, 9) REP(j, 9) cin >> field[i][j];
    
    REP(i, 9){
      REP(j, 9){
        table[i][j] = check(i, j);
      }
    }
    REP(i, 9){
      REP(j, 9){
        printf("%c%d", table[i][j], field[i][j]);
      }
      puts("");
    }
    if (n != 0) puts("");
  }

  return (0);
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main()
{
int l;
cin>>l;
int arr[l-1];
map<int,int>freq;
for(int i=0; i<l-1; ++i)
{
cin>>arr[i];
++freq[arr[i]];
}
for(int i=1; i<=l; ++i)
cout<<freq[i]<<"\n";
}


Measured memory_bytes: 13792
/*Author: Gautam*/


#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define INF 1e10
#define ull unsigned long long int

/* TYPE DEFINITIONS */
typedef		long long int	ll;
typedef		vector<ll>		vi;
typedef		pair<ll,ll>	    pi;



/* Prime Checker!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

/* MACROS */

#define  all(A)			(A).begin() , (A).end()
#define  rall(A)		(A).rbegin() , (A).rend()
#define  sz(A)			(int)(A).size()
#define  pb				push_back
#define  ppb			pop_back
#define  mp				make_pair
#define  ln(X)			(int)(X).length()
#define  square(X)		((X)*(X))
#define  cube(X)		((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)	for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
ll ncr(ll n, ll k)  
{  
    ll res = 1;  
  
    if ( k > n - k )  
        k = n - k;  
   
    for (ll i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
}  
void solve()
{
    
    ll n,c=0;
    cin>>n;
    unordered_map<string,ll> memo;
    forn(i,n)
    {
        string s;
        cin>>s;
        sort(all(s));
        //cout<<s<<endl;
        memo[s]++;
        //cout<<memo[s]<<endl;
    }
    for(auto i:memo)if(i.second>1)c+=ncr(i.second,2);
    cout<<c;
}   


int main()
{
	FastIO;
	ll t=1;
    //cin>>t;
    //double start_time = clock();
	while(t--)
    {
        solve();
    }
    //double end_time = clock();
   // printf( "\nTime = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
}

Measured memory_bytes: 10660
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for(int i=0;i<(n);i++)
#define pool(i,n) for(int i=(n)-1;i>=0;i--)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define tnoc(i,n) for(int i=(n);i>=1;i--)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define cric(i,a,b) for(int i=(b);i>=(a);i--)
#define sub(i,a) for(int i=a;i;i=((i-1)&(a)))
#define subs(i,a) for(int i=a;i>=0;i=(!i?-1:((i-1)&(a))))
#define subt(i,a) for(int i=((a-1)&a);i;i=((i-1)&(a)))
#define subst(i,a) for(int i=((a-1)&a);i>=0;i=(!i?-1:((i-1)&(a))))
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define parse(i,s) for(int i=0;s[i];i++)

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mak make_pair

#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define ws WSrAkIoi2333wSraKIoIWSraKiOi
#define left left_jTjTJtJtIoiiOiioIAuaU66666jtIOIau
#define hash whYusEthiSnamE_caNyoUusEothERnaMesliKeHSH

#define Mask(a) (1ll<<(a))
#define Maskx(a,x) ((a)<<(x))
#define Full(a) ((1ll<<(a))-1)
#define Bit(a,x) (((a)>>(x))&1)
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)((a).size()))

typedef long long ll;
typedef long double lf;

const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const lf inF=11451419198101145141919810.1145141919810;
const lf pi=acosl(-1);
/* Source code starts here */

int main(){
	int a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w||(abs(a-b)+abs(v-w)-1)/abs(v-w)>t)puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
int n, k;
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  // result
  int res = 1;
  ((n-k)%(k-1)==0)? res += (n-k)/(k-1) : res += (n-k)/(k-1) +1;
  cout << res <<'\n';

	return 0;
}

Measured memory_bytes: 640
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

a, b, c = ns().split(" ");

if(a[-1] == b[0] and b[-1] == c[0]):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for a in A for b in B]
AB.sort()
AB = AB[-K:]
ABC = [ab + c for ab in AB for c in C]
ABC.sort()
for v in ABC[-1:-K-1:-1]:
    print(v)


Measured memory_bytes: 137864
#include <stdio.h>

int main(void){
  int num;
  double Wei,Hei,BMI;

  while( scanf("%d,%lf,%lf" ,&num ,&Wei ,&Hei) != EOF ){

    BMI = Wei / (Hei*Hei); 
    if( BMI >= 25 ) printf("%d\n" ,num);

  }

  return 0;
}

Measured memory_bytes: 628
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass
    
if __name__ == '__main__':

    while True:
        try:
            n = int(input())

            ans = primes(n)
            print(len(ans))
            
        except EOFError:
            break


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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    vector<pair<int,int>> road(M*2);
    for (int i = 0; i < M; i++)
    {
        cin >> road[i].first >> road[i].second;
        road[i+M].first = road[i].second;
        road[i+M].second = road[i].first;
    }

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

    int ans = 0;
    int itr = 0;
    int flg;
    for (int i = 0; i < N; i++)
    {
        flg = 1;
        while(road[itr].first == i+1){
            if(H[i] <= H[road[itr].second-1]){
                flg = 0;
            }
            itr++;
        }
        if(flg){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
  int n,x;
  cin >> n >> x;
  int a[n];
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  int ans = 0;
  while(x >= a[ans]){
    x -= a[ans];
    ans++;
    if(ans==n){
      if(x>0){
        ans--;
        break;
      }else if(x==0){
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 2147483647
//static const double INF = (1 << 31)-1;

int n,q;
double d[400000],lazy[400000];
double x;

void lazy_evaluate(int k,int l,int r){
	if(lazy[k] == INF)return;
	else{
		d[k] = lazy[k];
		if(r - l > 1){
			lazy[2*k+1] = lazy[k];
			lazy[2*k+2] = lazy[k];
			/*
			lazy_evaluate(2*k+1);
			lazy_evaluate(2*k+2);
			*/
		}
		lazy[k] = INF;
	}
}
/*
void update(int k,double a){
	k += n - 1;
	d[k] = a;
	while(k > 0){
		k = (k - 1)/2;
		d[k] = min(d[k*2+1], d[k*2+2]);
	}
}
*/
void query(int a, int b, int k=0, int l=0, int r=-1){
	if(r < 0){
		r = n;
	}
	//cout << "haittemasu" << endl;
	
	lazy_evaluate(k,l,r);
	if(b <= l || r <= a) return;
	else if(a <= l && r <= b){
		lazy[k] = x;
		lazy_evaluate(k,l,r);
	}
	else{
		query(a,b,2*k+1,l,(l+r)/2);
		query(a,b,2*k+2,(l+r)/2,r);
		d[k] = min(d[2*k+1], d[2*k+2]);
	}
}

/*
double query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l){
		return INF;
	}
	else if(a <= l && r <= b){
		return d[k];
	}

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

double findMin(int a, int b){
	return query(a, b+1, 0, 0, n);
}
*/

double find(int a, int b, int k=0, int l=0, int r=-1){
	if(r < 0){
		r = n;
	}
	lazy_evaluate(k,l,r);
	if(b <= l || r <= a){
		return INF;
	}
	else if(a <= l && r <= b){
		return d[k];
	}

	double vl = find(a, b, k*2+1, l, (l + r)/2);
	double vr = find(a, b, k*2+2, (l + r)/2, r);
	return min(vl, vr);

}

int main(){
	int n_;
	cin >> n_ >> q;

	n=1;
	while(n<n_){
		n*=2;
	}
	for(int i = 0;i < n*2-1;i++){
		d[i] = INF;
		lazy[i] = INF;
	}
	int a, b, c;  
	double s,t;
	for(int i = 0;i < q;i++){
		cin >> a;
		if(a == 0){
			cin >> s >> t >> x;
			query(s,t+1);
		}
		else{
			cin >> b >> c;
			printf("%.0f\n",find(b,c+1));
		}
	}
	/*
	for(int i = 0;i < n*2-1;i++){
		cout << d[i] << endl;
	}
	*/
	return 0;
}



Measured memory_bytes: 7292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int a[100005];
void solve(){
    int n;
    cin>>n;
    int t;
    cin>>t;
    int profit = 0;
    int mn = 1e9+5;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mn = min(mn,a[i]);
        profit = max(profit,a[i]-mn);
    }
    int ans = 0;
    mn = 1e9+9;
    for(int i=1;i<=n;i++){
        mn = min(mn,a[i]);
        if(profit == a[i]-mn)ans++;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
//	cin>> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 768
import sys

# sys.stdin = open('b1.in')


h, w = map(int, input().split())
a = []
for i in range(h):
    ligne = input()
    a.append(ligne)

s = '#' * (w + 2)
print(s)
for ligne in a:
    l = list(ligne)
    l.append('#')
    l.insert(0, '#')
    ligne2 = ''.join(l)
    print(ligne2)
print(s)


Measured memory_bytes: 3060
N,M = gets.split.map(&:to_i)
 
g = Array.new(N){Array.new(N)}
 
M.times do |i|
  
  a,b = gets.split.map(&:to_i).sort.reverse
  a -= 1
  b -= 1
  g[a][b] = g[b][a] = 1
end
 
pattern = [*1...N].permutation.to_a.map{ |k| [0] + k }

ans = 0
pattern.each do |p|
  
  f = true
  (1...N).each do |i|
    p [p[i-1], p[i]]
    if g[p[i-1]][p[i]].nil?
      f = false
      break
    end
  end
  ans += 1 if f
end
 
puts ans

Measured memory_bytes: 3452
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sysin = new Scanner(System.in);
    int k = Integer.parseInt(sysin.nextLine());
    String s = sysin.nextLine();
    if(s.length() > k){
      System.out.print(s.substring(0, k) + "...");
    } else {
      System.out.print(s);
    }
  }
}

Measured memory_bytes: 38624
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;
	return f?-x:x;
}
int n,L,T,a[N],p;
int main(){
	n=read();L=read();T=read();
	For(i,1,n){
		int x=read(),y=read();
		if(y==1){
			a[i]=(x+T)%L;
			p=(p+(x+T-a[i])/L)%n;
		}else{
			a[i]=(x-T)%L;
			if(a[i]<0) a[i]+=L;
			p=(p+(x-T-a[i])/L)%n;
			if(p<0) p+=n;
		}
	}
	sort(a+1,a+1+n);
	For(i,p+1,n) cout<<a[i]<<endl;
	For(i,1,p) cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 1536
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int main() {
	int A, B; cin >> A >> B;
	if (A <= 5) cout << 0;
	else if (A >= 13) cout << B;
	else cout << B / 2;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
dp=[[float("inf") for _ in range(N)]for _ in range(N)]
for i in range(N):
    dp[i][i]=0
for _ in range(M):
    s,t,d=map(int,input().split())
    dp[s][t]=d

for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
flag=True
for v in range(N):
    if dp[v][v]<0:
        flag=False
        break

if flag:
    for i in range(N):
        for j in range(N):
            if dp[i][j]==float("inf"):
                dp[i][j]="INF"
    for i in range(N):
        print(*dp[i])
else:
    print("NEGATIVE CYCLE")


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

int find_gcd(int a, int b, int c) {
  int gcd;
  for (int i = a; i > 0; i--) {
    if (a % i == 0 && b % i == 0 && c % i == 0) {
      gcd = i;
      break;
    }
  }
  return gcd;
}

int main() {
  int K; cin >> K;
  vector<int> A(210);
  
  A[0] = 0;
  A[1] = 1;
  
  for (int k = 2; k <= K; k++) {
    int first = 0;
    for (int i = 1; i < k; i++) {
      for (int j = 1; j < k; j++) {
        first += find_gcd(i, j, k);
      }
    }
    
    int second = 0;
    for (int i = 1; i < k; i++) {
      second += find_gcd(i, k, k);
    }    
    A[k] = A[k-1] + 3 * first + 3 * second + k;
  }
  
  cout << A[K] << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>

using namespace std;

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

    int count = 0;

    while(true) {
        string t;
        cin >> t;

        if (t == "END_OF_TEXT")
            break;

        transform(t.begin(), t.end(), t.begin(), ::tolower);

        if (t == w)
            count++;
    }
    cout << count << endl;
    return 0;
}

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

#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
double pi= 3.14159265358979;
int M = 1000000007ll;
const int N=1e+5;
int dp[64];
void solve()
{   
	int a, b;cin>>a>>b; cout<<a*b;
}

signed main() 
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // cout<<setprecision(6);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();//cout<<'\n';
    }
    return 0;
}

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

using namespace std;


long long int parent = 0;
long long int recursive(vector<long long int>&len, long long int idx, vector<vector<long long int>>&E){
	if( len[idx] || idx == parent ){
		return len[idx];
	}
	for( auto e : E[idx] ){
		len[idx] = max(len[idx], recursive(len, e, E) + 1);
	}
	return len[idx];
}

int main(){
	long long int N, M;
	cin >> N >> M;
	vector<vector<long long int>>D(N), E(N);
	vector<long long int>count(N), count2(N);
	for( size_t i = 0; i < N + M - 1; i++ ){
		long long int a, b;
		cin >> a >> b;
		a--; b--;
		D[a].push_back(b);
		E[b].push_back(a);

		count[b]++;
		count2[a]++;
	}
	for( size_t i = 0; i < N; i++ ){
		if( count[i] == 0 ){
			parent = i;
			break;
		}
	}
	vector<long long int>len(N, 0);
	for( size_t i = 0; i < N; i++ ){
		recursive(len, i, E);
	}

	vector<long long int>parentid(N, 0);

	len[parent] = 0;
	queue<pair<long long int, long long int>>que;
	que.push(make_pair(parent, 0));
	while( que.size() ){
		auto now = que.front(); que.pop();
		if( len[now.first] != now.second ){
			continue;
		}

		for( auto d : D[now.first] ){
			if( len[d] == now.second + 1 ){
				parentid[d] = now.first + 1;

				que.push(make_pair(d, now.second + 1));
			}
		}
	}

	for( size_t i = 0; i < N; i++ ){
		cout << parentid[i] << endl;
	}
}


Measured memory_bytes: 18816
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toDouble() }.toDoubleArray()
    v.sort()

    v[0] /= 2.0
    v[1] /= 2.0

    (2 until N).forEach { i ->
        (0 .. i).forEach { j ->
            v[j] /= 2.0
        }
    }
    println(v.sum())
}

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


n,m = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]

MOD = 10**9+7
ls = n
lt = m

dp = [[0]*(lt+1) for _ in [0]*(ls+1)]
dp[0] = [1]*(lt+1)
for j in range(ls+1):
    dp[j][0] = 1

for i in range(1,ls+1):
    for j in range(1,lt+1):
        if s[i-1] != t[j-1]:
#            dp[i][j] = dp[i-1][j] + dp[i][j-1]
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j] -  dp[i - 1][j - 1];
            dp[i][j] %= MOD
        else:
#            dp[i][j] = dp[i-1][j] + dp[i][j-1] + dp[i-1][j] + 2*dp[i-1][j-1]
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
            dp[i][j] %= MOD

#print(dp)
print(dp[n][m])






Measured memory_bytes: 73308
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[107][107];
int main(){
	Lancer();
	ll n, arr[] = {111,222,333,444,555,666,777,888,999};
	cin >> n;
	for (int i = 0; i <9; i++){
		if (arr[i] >= n){
			cout << arr[i];
			return 0;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3672
n = int(input())
h = list(map(int , input().split()))
h.append(0)
n += 1
ans = 0
prevans = -1
while ans != prevans:
    prevans = ans
    prev = h[0]
    for i in range(n):
        if prev != 0 and h[i] == 0:
            ans += 1
        prev = h[i]
        if h[i] != 0:
            h[i] -= 1
print(ans)




Measured memory_bytes: 39152
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
l = []
for i in range(n-1):
    l.append(x[i+1]-x[i])
    
exh = 0
li = b / a
for i in l:
    if i > li:
        exh += b
    else:
        exh += a*i
        
print(exh)

Measured memory_bytes: 63468
N,M=[int(x) for x in input().split()]
G=[-1] * N
W=[0] * N
E=[]

result=[]
ans = int(N * (N-1) / 2)

def union(i,j):
    gi=find(i)
    gj=find(j)

    if(gi!=gj):
        if W[gi] > W[gj]:
            G[gi]+=G[gj]
            G[gj]=gi
        else:
            G[gj]+=G[gi]
            G[gi]=gj
            if W[gi]==W[gj]:
                W[gj]+=1

def find(i):
    if G[i]<0:
        return i;
    else:
        G[i]=find(G[i])
        return G[i]

for m in range(M):
    A,B=[int(x) for x in input().split()]
    E.append((A-1,B-1))

for m in range(M):
    result.append(ans)
    if(ans>0):
        A,B=E.pop()
        ga,gb=find(A),find(B)
        if (ga!=gb):
            ans=ans-(G[ga]*G[gb])
            union(A,B)

for r in reversed(result):
    print(r)


Measured memory_bytes: 19320
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

nl = []

for i in range(N):
  nl += [str(i+1)] * A[i]

#print(nl)

for i in range(H):
  work = nl[i*W:(i+1)*W]
  if i%2 == 1:
    work.reverse()
  print(" ".join(work))

Measured memory_bytes: 40560
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	ll n;
	unordered_set<ll> ans;
	cin >> n;
	ans.insert(n);
	for(ll i = 2; i * i <= n; i++) {
		if(!(n%i)) {
			ll a = i;
			ll b = n/i;
			ll x = n;
			while(!(x%a))
				x/=a;
			if(x%a == 1)
				ans.insert(a);
			x = n;
			while(!(x%b))
				x/=b;
			if(x%b == 1)
				ans.insert(b);
		}
	}
	n--;
	for(ll i = 2; i * i <= n; i++) {
		if(!(n%i)) {
			ans.insert(i);
			ans.insert(n/i);
		}
	}
	ans.insert(n);
	ans.erase(1);
	cout << ans.size();

	return 0;
}


Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


S=ns()
if(S=='RRR'):
    print(3)
if(S=='RRS' or S=='SRR'):
    print(2)
if(S=='RSS' or S=='SRS' or S=='SSR' or S=='RSR'):
    print(1)
if(S=='SSS'):
    print(0)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int h, w;
vector<string> a;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
bool ans = true;

void dfs(int x = 0, int y = 0, int xx = -1, int yy = -1){
    if(x == h - 1 && y == w - 1){
        if(a[x][y] == '#') {
            if(ans) ans = true;
        }
    }
        rep3(i, 2, 3){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx == xx && ny == yy) continue;
            if(nx < 0 || nx >= h) continue;
            if(ny < 0 || ny >= w) continue;
            if(a[nx][ny] == '#') {
                ans = false; 
                return;
            }
        }
        
        int flag = 0;
        rep3(i, 0, 1){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx >= h || ny >= w) flag++;
            else if(a[nx][ny] == '.') {
                flag++;
            }else{
                flag = 0;
                // cout << "dfs: " << nx << " " << ny << " "  << x << " " << y << endl;
                dfs(nx, ny, x, y);
            }
        }
        if(flag == 2 && !(x == h-1 && y == w-1)) {
            ans = false; 
            return;
        }
}

void Main(){
    cin >> h >> w;
    a.resize(h); 
    rep(i, h) cin >> a[i];
    
    dfs();
    if(ans) cout << "Possible" << endl;
    else cout << "Impossible" << endl; 
    
    return;
}

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

Measured memory_bytes: 3636
N=int(input())
if N%2==1:
    hen=[]
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i+j!=N:
                hen.append([i,j])

    M=len(hen)
    print(M)
    for i in range(0,M):
        print(*hen[i])

else:
    hen=[]
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i+j!=N+1:
                hen.append([i,j])

    M=len(hen)
    print(M)
    for i in range(0,M):
        print(*hen[i])

Measured memory_bytes: 43376