akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
struct E{int v,next;}g[200005];
int n,m,q,h[100005],v[100005],d[100005],c[100005],color[100005],t,dis[100005];
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
void ins(int u,int v){g[++t].v=v,g[t].next=h[u],h[u]=t;}
void dfs(int v,int d,int c){
	if(d==0||dis[v]>=d) return;
	dis[v]=d; if(color[v]==0) color[v]=c;
	for(int i=h[v];i;i=g[i].next) dfs(g[i].v,d-1,c);
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;++i){
		int u,v;
		u=read(),v=read();
		ins(u,v),ins(v,u);
	}
	q=read();
	for(int i=1;i<=q;++i) v[i]=read(),d[i]=read(),c[i]=read();
	for(int i=q;i>=1;--i) dfs(v[i],d[i]+1,c[i]);
	for(int i=1;i<=n;++i) printf("%d\n",color[i]);
}

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

int main()
{
    int n,m,x,y,z,t=0;
    int a[1000],b[1000];
    cin >> n >> m >> x >> y;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<m;i++)
        cin >> b[i];
    if(*max_element(a,a+n)<*min_element(b,b+m))
        if(y>x)
        if(x<*min_element(b,b+m)&&y>*max_element(a,a+n))
        t=1;
    if(t)
        printf("No War\n");
    else
        printf("War\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> P;
vector<P> V1,V2;
set<P> S;
bool check(int x) {
	for(int i=0;i<V1.size();i++) {
		int nx=V1[i].first-V1[0].first,ny=V1[i].second-V1[0].second;
		if(S.find(P(V2[x].first+nx,V2[x].second+ny))==S.end()) {
			return false;
		}
	}
	return true;
}
int main() {
	int n,m;
	while(scanf("%d",&m),m) {
		V1.clear();
		for(int i=0;i<m;i++) {
			int x,y;
			scanf("%d %d",&x,&y);
			V1.push_back(P(x,y));
		}
		scanf("%d",&n);
		V2.clear();
		S.clear();
		for(int i=0;i<n;i++) {
			int x,y;
			scanf("%d %d",&x,&y);
			V2.push_back(P(x,y));
			S.insert(P(x,y));
		}
		for(int i=0;i<V2.size();i++) {
			if(check(i)) {
				printf("%d %d\n",V2[i].first-V1[0].first,V2[i].second-V1[0].second);
				break;
			}
		}
	}
}

Measured memory_bytes: 1248
//**************************
//*** author  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define int long long

int n;
struct thing{
	int a,b;
	int dif;
	void input(){
		scanf("%lld%lld",&a,&b);
		dif=a+b;
	}
};

bool operator<(thing a,thing b){
	return a.dif!=b.dif?a.dif>b.dif:a.a>b.a;
}

multiset<thing>th;

signed main(){
	scanf("%lld",&n);
	for(int i=0;i<n;i++){
		thing t;
		t.input();
		th.insert(t);
	}
	cerr<<"ok init\n";
	int ans=0;
	for(int i=0;i<n;i++){
		if(i&1){
			ans-=(*th.begin()).b;
		}else{
			ans+=(*th.begin()).a;
		}
		th.erase(th.begin());
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int cnt[10];

bool all_zero() {
    for (int i = 1; i < 10; i++) 
        if (cnt[i] > 0) 
            return false;
    return true;
}

bool dfs() {
    if (all_zero()) return true;
    for (int i = 1; i < 10; i++) {
        if (cnt[i] >= 3) {
            cnt[i] -= 3;
            if (dfs()) {
                cnt[i] += 3;
                return true;
            }
            cnt[i] += 3;
        }
        if (i >= 2 && cnt[i-2] && cnt[i-1] && cnt[i]) {
            cnt[i-2]--; cnt[i-1]--; cnt[i]--;
            if (dfs()) {
                cnt[i-2]++; cnt[i-1]++; cnt[i]++;
                return true;
            }
            cnt[i-2]++; cnt[i-1]++; cnt[i]++;
        }
    }
    return false;
}

bool check() {
//    for (int i = 1; i < 10; i++) {
//        cout << cnt[i] << ' ';
//    }
//    cout << endl;
    for (int i = 1; i < 10; i++) {
        if (cnt[i] >= 2) {
            cnt[i] -= 2;
            if (dfs()) {
                cnt[i] += 2;
                return true;
            }
            cnt[i] += 2;
        }
    }
    return false;
}

bool check_over() {
    for (int i = 1; i < 10; i++) 
        if (cnt[i] > 4) 
            return false;
    return true;
}

int main() {
    string s;
    while (cin >> s) {
        memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < s.size(); i++) cnt[s[i]-'0']++;

        bool first = true;
        bool found = false;
        for (int i = 1; i < 10; i++) {
            cnt[i]++;
            if (check_over() && check()) {
                if (first) {
                    cout << i;
                    first = false;
                } else {
                    cout << ' ' << i;
                }
                found = true;
            }
            cnt[i]--;
        }
        if (!found) cout << 0;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<long long,int>,vector< pair<long long,int > >,less< pair<long long,int> > >pq;
int num[100001];
int a[100001];
int main(){
	int n,k;
	cin>>n>>k;
	 long long ans=0;
	for(int i=1 ; i<=n ; i++){
		int x;
		cin>>a[i];
		pq.push(make_pair(a[i],i));
	}
	while(k>0 && !pq.empty()){
			
			pair<long long,int> chosen=pq.top();
			num[chosen.second]++;
			pq.pop();
			pq.push(make_pair(chosen.first/2,chosen.second));
			k--;
	}
	for(int i=1;i<=n;i++){
		ans+=a[i]/pow(2,num[i]);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 2676
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n, x, t = MII()
    ans = n//x * t
    if n%x != 0:
        ans += t
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <stdio.h>


int main(void) {

	// 1_2-B Range
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b && b<c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
        return 0;
}

Measured memory_bytes: 580
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <utility>
#include <sstream>
#include <random>
using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	int sx, sy;
	vector<bool>opened(H * W);
	vector<bool>reached(H * W);
	auto Index = [&](int x, int y)->int{
		return x + y * W;
	};
	for (int i = 0; i < H * W; i++)
	{
		char m;
		cin >> m;
		if (m == 'S') {
			sx = i % W;
			sy = i / W;
		}
		opened[i] = (m != '#') ? true : false;
		reached[i] = false;
	}

	int MC = 1;

	int sr;
	priority_queue<pair<int, int>  > moveque;
	auto push_move = [&](int range, int x,int y) {
		if (range == 0)return;
		int index = Index(x, y);
		if (!opened[index] || reached[index])return;
		moveque.push({ range ,index });
		reached[index] = true;
		sr = min(sr,min(min(x, W - x - 1), min(y, H - y - 1)));
	};

	sr = min(min(sx, W - sx - 1), min(sy, H - sy - 1));
	push_move(K + 1, sx, sy);

	while(moveque.size()){
		auto val = moveque.top();
		moveque.pop();
		int x = val.second % W;
		int y = val.second / W;
		if (x > 0)push_move(val.first - 1, x -1, y);
		if (x < W - 1)push_move(val.first - 1, x + 1, y);
		if (y > 0)push_move(val.first - 1, x, y - 1);
		if (y < H -1)push_move(val.first - 1, x, y + 1);
	};

	if (sr == 0) MC = 1;
	else {
		MC = (sr - 1) / K + 2;
	}
	cout << MC;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            String s = sc.next(); 							//アルファベットの入力
            if(s.equals("-")) {								//"-"のときfor文の後ろに移動する
            	break;
            }
            int m = sc.nextInt();							//シャッフル回数の入力
            for(int i = 0; i < m; i++){
                int h = sc.nextInt();						//取り出すカードの後ろからの枚数
                s = s.substring(h) + s.substring(0, h);		//指定した位置から最後まで切り取り、先頭にくっつける
            }
            System.out.println(s);
        }

    }
}


Measured memory_bytes: 26636
def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    D = [0] * (n+1)
    now = 1
    for i in range(1, k+1):
        tmp = A[now-1]
        if not D[tmp]:
            now = tmp
            D[now] += i
        else:
            pre = D[tmp]
            loop = i - D[tmp]
            print(D.index((k - pre) % loop + pre) if loop > 1 else tmp)
            return
    print(now)
main()

Measured memory_bytes: 32384
import sys
import numpy as np
import itertools
import collections
from collections import deque

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

h = itertools.combinations_with_replacement
p = itertools.permutations

def main():
    # input
    A, B, C = map(int, input().split())
    tmp = B
    B = A
    A = tmp

    tmp = C
    C = A
    A = tmp

    print("{} {} {}".format(A, B, C))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14240
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, A, B = map(int, input().split())
        if abs(A - B) % 2 == 1:
            print('Borys')
        else:
            print('Alice')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38384
import numpy as np
lis=np.array(list(map(int,input().split())))
cnt=0
for i in range(1000000):
    if lis[0]%2==0 and lis[1]%2==0 and lis[2]%2==0:
        if lis[0]==lis[1]==lis[2]:
            print('-1')
            break
        else:   
            lis=lis/2
            a=lis[1]+lis[2]
            b=lis[0]+lis[2]
            c=lis[0]+lis[1]
            lis[0]=a
            lis[1]=b
            lis[2]=c
            cnt+=1
    else:
        print(cnt)
        break

Measured memory_bytes: 27108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin >> N;
  N = 10000-N;
  N %= 1000;
  cout << N << endl;
}


Measured memory_bytes: 3624
N = int(input())
hashmap = {}
Array = [[] for _ in range(N+1)]
for _ in range(N):
  st = input()
  if st not in hashmap:
    hashmap[st] = 0
  hashmap[st]+=1
max_num = max(hashmap.values())
tup = []
for k,v in hashmap.items():
  if v == max_num:
    tup.append(k)
tup.sort()
for i in tup:
  print(i)

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

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

    vector<int> v(n);
    vector<double> d(n-1);

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

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

    d[0]=((double)v[0]+(double)v[1])/2;

    for(int i=1; i<n-1; i++){
        d[i]=(d[i-1]+v[i+1])/2;
    }

    cout<<d[n-2]<<endl;
}

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

int main() {
	queue<int> que1;
	queue<string> que2;
	int n, q;
	cin >> n >> q;
	for(int i=0; i<n; i++){
		string str;
		cin >> str;
		que2.push(str);
		int x;
		cin >> x;
		que1.push(x);
	}
	
	int count = 0;
	while(!que1.empty()){
		int cur = que1.front(); que1.pop();
		string str = que2.front(); que2.pop();
		if( q >= cur ){
			count += cur;
			cout << str << " " << count << endl;
		}else{
			count += q;
			que1.push(cur-q);
			que2.push(str);
		}
	}
	
	return 0;
}

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

int S[100000];

bool binarysearch(int key, int left, int right){
    int mid = (left+right)/2;
    if(left == right) return false;
    if(S[mid] == key) return true;
    else if(S[mid] < key) binarysearch(key, mid+1, right);
    else binarysearch(key, left, mid);
}

int main(){
    int key, n, q, cnt = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> key;
        if(binarysearch(key, 0, n)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3436
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
//#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.14159265358979323846
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;



int main(void){
    ll n,m;
    cin>>n>>m;
    vvl nexts(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        nexts[a].push_back(b);
        nexts[b].push_back(a);
    }
    vl ans(n,-1);
    ans[0] = 0;
    queue<ll> q;
    q.push(0);
    while(q.empty() == false){
        ll now = q.front();
        q.pop();
        for(ll next:nexts[now]){
            if(ans[next] != -1) continue;
            q.push(next);
            ans[next] = now;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n-1){
        cout<<ans[i+1]+1<<endl;
    }
}

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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;


signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        int n;
        cin>>n;
        int a[n];
        int sum=0;
        int curr=0;
        int ans=0;
        f(i,0,n-1)
        {
            cin>>a[i];
            int curr=(sum * a[i])%mod;
            ans=(ans+curr)%mod;
            sum=(sum+a[i])%mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 5188
let () =
    let max = 999999 in
    let is_primes = Array.make (max+1) true in
    for x = 2 to max / 2 do
        if is_primes.(x) then (
            for y = 2 to max / x do
                Array.set is_primes (x*y) false
            done ;
        ) ;
    done ;

    let n_primes = Array.make (max+1) 0 in
    let count    = ref 0 in
    for x = 2 to max do
        if is_primes.(x) then (
            count := !count + 1
        ) ;
        n_primes.(x) <- !count
    done ;

    try
        while true do
            let n = read_int () in
            Printf.printf "%d\n" (n_primes.(n))
        done
    with
        End_of_file -> ()

Measured memory_bytes: 18244
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>

using namespace std;


int main(){
    int r, d;
    vector<int> x(11);
    cin >> r >> d >> x[0];
    for (int i = 1; i <= 10; i++)
        x[i] = x[i-1] * r - d;

    x.erase(x.begin());
    stringstream ss;
    for (int i = 1; i <= 10; i++)
    {
        if (i != 1)
            ss << "\n";
        ss << x[i-1];
    }
    cout << ss.str() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

double n, k, c, x, t;

int main(){

    cin >> n >> k;

    for(int i = 1; i <= n; i++){
        for(int j = 0; ;j++){
            if(i*(int)pow(2,j) >= k){
                t = j;
                break;
            }
        }
        x += (1/(double)n)*pow(0.5,t);

    }

    cout << fixed << setprecision(12) << x;







}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

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

#define MAX 100001

using namespace std;

vector<int> graph[MAX];
bool vis[MAX];
int sign[MAX];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, a, b;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    memset(sign, 0, sizeof sign);
    queue<int> q;
    q.push(1);
    vis[1] = true;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto const &val : graph[u]) {
            if (!vis[val]) {
                vis[val] = true;
                q.push(val);
                sign[val] = u;
            }
        }
    }
    for (int i = 2; i <= n; ++i) {
        if (sign[i] == 0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; ++i) {
        cout << sign[i] << '\n';
    }
}


Measured memory_bytes: 10596
#include<bits/stdc++.h>
#define mo 1000000007
#define N 1000005
using namespace std;
int n,fac[N],inv[N];
int C(int x,int y){
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	scanf("%d",&n);
	fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<=n;i++)
		inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	for (int i=1;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=1ll*inv[i-1]*inv[i]%mo; 
	}
	int ans=1ll*(n-1)*fac[n-1]%mo;
	for (int i=(n+1)/2;i<n-1;i++)
		ans=(ans+mo-1ll*fac[i]*fac[n-1-i]%mo*C(i-1,n-i-1)%mo)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 8064
N = int(input())
A = list(map(int,input().split()))
B = [0 for _ in range(N//2)]
for i in range(0,N,2):
    B[i//2] = A[i]^A[i+1]
tot = 0
for i in range(N//2):
    tot = tot^B[i]
X = [0 for _ in range(N)]
for i in range(N//2):
    y = tot^B[i]
    X[2*i]=A[2*i+1]^y
    X[2*i+1]=A[2*i]^y
print(*X)

Measured memory_bytes: 120992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

// bool pairCompare(const P& firstElof, const P& secondElof){
//     return firstElof.first > secondElof.first;
// }

int main(int argc, char**argv){
    int n;
    cin >> n;
    string s;
    int p;
    vector<pair<pair<string, int>, int> > sp;
    for (int i = 0; i < n; i++){
        cin >> s >> p;
        sp.push_back(make_pair(make_pair(s, -p), i+1));
    }

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

    for (int i = 0; i < n; i++){
        cout << sp[i].second << endl;
    }

    return 0;
}
















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

ld dist(ld x1,ld y1,ld x2,ld y2){
    return (ld)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ld xs;
    cin >> xs;
    ld ys;
    cin >> ys;
    ld xt;
    cin >> xt;
    ld yt;
    cin >> yt;
    ld N;
    cin >> N;
    vector<ld> x(N+2,0.0);
    vector<ld> y(N+2,0.0);
    vector<ld> r(N+2,0.0);
    x[0]=xs;y[0]=ys;
    x[N+1]=xt;y[N+1]=yt;
    for(ll i=1;i<=N;++i)cin>>x[i]>>y[i]>>r[i];
    vector<vector<pair<ll,ld>>> G(N+2, vector<pair<ll,ld>>(0));
    for(ll i=0;i<N+2;++i){
        for(ll j=i+1;j<N+2;++j){
            ld h=dist(x[i],y[i],x[j],y[j])-r[i]-r[j];
            if(h>0.0){
                G[i].emplace_back(pair<ll,ld>(j,h));
                G[j].emplace_back(pair<ll,ld>(i,h));
            }
            else {
                G[i].emplace_back(pair<ll,ld>(j,0.0));
                G[j].emplace_back(pair<ll,ld>(i,0.0));
            }
        }
    }

    //ダイクストラ法
    //vvl GにP(to,cost)って感じで隣接リストにしておく
    //計算量|E|log|V|
    //頂点数N
    priority_queue<pair<ld,ll>, vector<pair<ld,ll>>, greater<pair<ld,ll>>> pq;
    vector<ld> d(N+2,INF);
    d[0]=0.0;
    pq.emplace(P(0.0,0));
    while(!pq.empty()){
        P w=pq.top();
        pq.pop();
        ld Y=w.first;
        ll z=w.second;
        if(Y>d[z])continue;
        for(auto p: G[z]){
            if(d[p.first]>d[z]+p.second){
                d[p.first]=d[z]+p.second;
                pq.emplace(P(d[p.first],p.first));
            }
        }
    }

    cout << fixed << setprecision(10);


    prt(d[N+1])

    

    return 0;
}


Measured memory_bytes: 42544
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[11000][110] = {};

int main(){
	
	string K;
	cin >> K;
	
	int D;
	cin >> D;
	
	for(int i = 0; i < K.size(); i++){
		K[i] = K[i] - '0';
	}
	
	DP[0][0] = 1;
	for(int i = 0; i < K.size(); i++){
		for(int j = 0; j < D; j++){
			for(int k = 0; k < 10; k++){
				DP[i + 1][(j + k) % D] += DP[i][j];
				DP[i + 1][(j + k) % D] %= MOD;
			}
		}
	}
	
	long long int ans = 0;
	int cur = 0;
	for(int i = 0; i < K.size(); i++){
		for(int j = 0; j < K[i]; j++){
			ans += DP[K.size() - i - 1][(D * 1000 - cur - j) % D];
			ans %= MOD;
		}
		cur += K[i];
		cur %= D;
	}
	
	ans += MOD - 1;
	ans %= MOD;
	
	if(cur == 0){
		ans += 1;
		ans %= MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int x,y;
int main(){
	cin >> x >> y;
	int ans = INF;
	if(-x<=y)ans = min(ans,1+y+x);
	if(y>=x)ans = min(ans,y-x);
	if(x<=-y)ans = min(ans,1-y-x);
	if(-x<=-y)ans = min(ans,2-y+x);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = 0
for b in range(1, N+1):
    p = N // b
    ans += p * max(b - K, 0)
    # if K <= N % b:
    ans += max(N % b - K + 1, 0) 
    if K == 0:
        ans -= 1
print(ans)



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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

#define mod 1e9+7

int main(){
  int N;
  cin >> N;
  vector<int> sosu(N+1, 1);
  FOR(i, 2, N+1){
    if(sosu[i] == 0){
      continue;
    }
    for(int j = 2; i*j <= N; j++){
      sosu[i*j] = 0;
    }
  }
  ll ans = 1;
  FOR(i, 2, N+1){
    if(sosu[i] == 1){
      int x = 0;
      for(int j = i; j <= N; j*=i){
        x += N / j;
      }
      x += 1;
      ans *= x;
      ans = ans % 1000000007;
      //cout << x << " " << ans << endl;
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
N = len(S)

memo_s = {"a":-1,"b":-1,"c":-1,"d":-1,"e":-1,"f":-1,"g":-1,"h":-1,"i":-1,"j":-1,"k":-1,"l":-1,"m":-1,"n":-1,"o":-1,"p":-1,"q":-1,"r":-1,"s":-1,"t":-1,"u":-1,"v":-1,"w":-1,"x":-1,"y":-1,"z":-1}
memo_t = {"a":-1,"b":-1,"c":-1,"d":-1,"e":-1,"f":-1,"g":-1,"h":-1,"i":-1,"j":-1,"k":-1,"l":-1,"m":-1,"n":-1,"o":-1,"p":-1,"q":-1,"r":-1,"s":-1,"t":-1,"u":-1,"v":-1,"w":-1,"x":-1,"y":-1,"z":-1}

for i in range(N):
    if memo_s[S[i]] == -1 and memo_t[T[i]] == -1:
        memo_s[S[i]] = T[i]
        memo_t[T[i]] = S[i]
    else:
        if memo_s[S[i]] != T[i] or memo_t[T[i]] != S[i]:
            print("No")
            quit()

print("Yes")


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int A, B;
  cin >> A >> B;
  if (A >= 13) cout << B << endl;
  else if (A < 6) cout << 0 << endl;
  else cout << B/2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=pow(10,9)+7;
vector<vector<ll>>dp;
ll solve(vector<vector<ll>>&arr,ll n,ll start,ll choice){
  if(start==n)return 0;
  if(dp[start][choice]!=-1)return dp[start][choice];
  if(choice==0){
    dp[start][choice]=arr[start][choice]+max(solve(arr,n,start+1,1),solve(arr,n,start+1,2));
  }
  else if(choice==1){
    dp[start][choice]=arr[start][choice]+max(solve(arr,n,start+1,0),solve(arr,n,start+1,2));
  }
  else if(choice==2){
    dp[start][choice]=arr[start][choice]+max(solve(arr,n,start+1,1),solve(arr,n,start+1,0));
  }
  return dp[start][choice];
}
int main(){
  ll n;
  cin>>n;
  vector<vector<ll>>arr(n,vector<ll>(3,0));
  for(int i=0;i<n;i++){
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
  dp=vector<vector<ll>>(n+1,vector<ll>(3,-1));
  ll start=0;ll choice=0;ll ans=-1;
  for(int j=0;j<3;j++){
    ans=max(ans,solve(arr,n,start,j));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 20312
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

//144 B
int main(void) {
	string s = "No";
	ll n;
	cin >> n;
	rep(i, 1, 10) {
		if (n % i == 0 && n / i <= 9 && 1 <= n / i) {
			s = "Yes";
			break;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] str=br.readLine().split(" ");
		int a=Integer.parseInt(str[0]);
		int b=Integer.parseInt(str[1]);
		
		int d=a/b;
		int e=a%b;
		double f=(double)a/b;
		
		System.out.printf("%d %d %.5f\n",d,e,f);
				
	}

}

Measured memory_bytes: 16928
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
que = deque()
A = [input() for i in range(H)]

dist = [[-1]*W for i in range(H)]
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      dist[i][j] = 0
      que.append((i, j))

d = 0
while que:
  y, x = que.popleft()
  d = dist[y][x]
  for dx, dy in dd:
    nx = x + dx; ny = y + dy
    if not 0 <= nx < W or not 0 <= ny < H or dist[ny][nx] != -1:
      continue
    dist[ny][nx] = d + 1
    que.append((ny, nx))

print(d)

Measured memory_bytes: 88028
INF = 10 ** 20
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left
from functools import reduce
from fractions import gcd

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    if k > max(a):
        print('IMPOSSIBLE')
        return

    G = reduce(gcd,a)
    if k%G == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
if __name__ == '__main__':
    main()


Measured memory_bytes: 16292
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}
 
 
 
 
 
void test_case()
{
    
    
    string s,t;
    cin>>s>>t;

    string ans = t+s;
    cout<<ans<<endl;


 
    
}
 
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3612
n = int(input())
ans = [0] * (n+1)
for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            temp = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= temp <= n:
                ans[temp] += 1
print(*ans[1:], sep='\n')

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

int main() {
  vector<int> a(5);
  for (auto& e : a) cin >> e;
  int k; cin >> k;

  if (a.at(4) - a.at(0) > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

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

int main() {
  int N,K,S;
  cin >> N >> K >> S;
  
  for(int i=0;i<K;i++) cout << S << " ";
  if(S==1000000000){
    for(int i=K;i<N;i++) cout << 1 << " ";
  }
  else{
    for(int i=K;i<N;i++) cout << S+1 << " ";
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long x,y,ans=LINF;

int main() {
    cin >> x >> y;
    if(x<=y) ans=min(ans,y-x);
    if(-x<=y) ans=min(ans,y+x+1);
    if(x<=-y) ans=min(ans,-y-x+1);
    if(-x<=-y) ans=min(ans,-y+x+2);
    cout << ans;
}


Measured memory_bytes: 256
s= input()
V = list(s)
X = [chr(ord('a') + i) for i in range(26)]

if len(s)<26:
  for i in range(26):
    count1 = s.count(X[i])
    if count1 >= 1:
      continue
    else:
      Nasi = X[i]
      break
  ans = s + Nasi
else:
  if s == "zyxwvutsrqponmlkjihgfedcba":
    ans= -1
  else:
    for i in range(25, 0, -1):
        if V[i] > V[i-1]:
          ans = V[0:i-1]
          if ans == []:
            ans = chr(ord(V[0]) + 1)
          else:
              B = min(V[i:26])
              while B <= V[i-1]:
                  B = chr(ord(B) + 1)
              while B in ans:
                  B = chr(ord(B) + 1)
              ans.append(B)
              ans = ''.join(ans)
              break
        else:
            continue
print(ans)

Measured memory_bytes: 3064
from itertools import product


def main():
    N, M = map(int, input().split())
    conn = [
        list(map(int, input().split()[1:]))
        for _ in range(M)
    ]
    conds = list(map(int, input().split()))

    print(len([
        state
        for state in product(("ON", "OFF"), repeat=N)
        if all(
            len([s for s in switches if state[s - 1] == "ON"]) % 2 == p
            for switches, p in zip(conn, conds)
        )
    ]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
from math import ceil
a,b,c,d=[int(x) for x in input().split()]
if ceil(a/d)==ceil(c/b):
    print('Yes')
elif ceil(a/d)>ceil(c/b):
    print('Yes')
elif ceil(a/d)<ceil(c/b):
    print('No')
else:print('No')

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

int main() {
  int N;
  cin >> N;
  int A[N];
  int B[N-1];
  for (int i = 0; i < N-1; i++) {
    cin >> B[i];
  }
  
  A[0] = B[0];
  A[N-1] = B[N-2];
  for (int i = 1; i <= N-2; i++) {
    A[i] = min(B[i-1],B[i]);
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#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 mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    if (a%3==0||b%3==0||(a+b)%3==0){
        cout<<"Possible\n";
    }else{
        cout<<"Impossible\n";
    }
    return 0;
}


Measured memory_bytes: 256
import Data.Monoid
import Control.Monad.State

data Seg a = Nil | Seg Int a (Seg a) (Seg a) deriving (Show, Eq)

initSeg :: (Monoid m) => Int -> Seg m
initSeg 0 = Nil
initSeg n = Seg n mempty (initSeg (n-1)) (initSeg (n-1))

updateSeg :: (Monoid m) => Int -> m -> Seg m -> Seg m
updateSeg 0 a (Seg 1 _ _ _) = Seg 1 a Nil Nil
updateSeg _ _ s@(Seg 1 _ _ _) = s
updateSeg k a (Seg n b l@(Seg _ al _ _) r@(Seg _ ar _ _))
  | k < c = Seg n (mappend al' ar) l' r
  | otherwise = Seg n (mappend al ar') l r'
  where 
    c = 2^(n-2)
    l'@(Seg _ al' _ _) = updateSeg k a l
    r'@(Seg _ ar' _ _) = updateSeg (k-c) a r

querySeg :: (Monoid m) => Int -> Int -> Seg m -> m
querySeg 0 1 (Seg 1 a _ _) = a
querySeg _ _ (Seg 1 _ _ _) = mempty
querySeg i j s@(Seg n a l r)
  | i == 0 && j == 2*c = a
  | j < c = querySeg i j l
  | c <= i = querySeg (i-c) (j-c) r
  | otherwise = mappend (querySeg i c l) (querySeg 0 (j-c) r)
  where
    c = 2^(n-2)

newtype Min = Min Int deriving Show
instance Monoid Min where
  mempty = Min (2^31 - 1)
  mappend (Min a) (Min b) = Min (min a b)

fromMin (Min a) = a

getNums :: IO [Int]
getNums = liftM (map read . words) getLine

main = do
  n:q:_ <- getNums
  let depth = 1 + ((ceiling $ logBase 2 (fromIntegral n))) in
    evalStateT (replicateM_ q proc) $ initSeg depth

proc :: StateT (Seg Min) IO ()
proc = do
  com:x:y:_ <- lift $ getNums
  case com of
    0 -> modify $ updateSeg x (Min y)
    1 -> do
      s <- get
      lift $ print $ fromMin $ querySeg x (y+1) s

Measured memory_bytes: 74068
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
   ios_base :: sync_with_stdio(false);
   cin.tie(NULL);
   string a,b;
   cin>>a>>b;
   int r = a.size();
   int c = b.size(); 
   vector<vector<int>>dp(a.size()+1, vector<int>(b.size()+1));
   for(int i=0;i<=r;i++){
       for(int j=0;j<=c;j++){
           if(i==0 || j==0)
            dp[i][j]=0;
           else{
               if(a[i-1]==b[j-1]){
                   dp[i][j]=1+dp[i-1][j-1];
               }
               else
                   dp[i][j]=max(dp[i-1][j], dp[i][j-1]); 
           } 
          // cout<<dp[i][j]<<" "; 
        }
        //cout<<"\n";
    }
    string ans="";
    int i=r,j=c;
    while(i!=0 && j!=0){
        if(a[i-1]==b[j-1]){
            ans=a[i-1]+ans;
            i--;j--;
        }
        else{
            if(dp[i][j-1]>dp[i-1][j])
                j--;
            else
                i--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35584
#![allow(dead_code)]
use std::io;

fn main() {
    solve_c();
}

fn solve_c() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let mut v: Vec<u32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<u32>().unwrap())
        .collect();

    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}



Measured memory_bytes: 5036
#include <iostream>
#include <vector>
//#include "../cxx-prettyprint/prettyprint.hpp"

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

    std::vector<std::vector<int>> Adj;
    Adj.assign(n + 1, std::vector<int>(n + 1, 0));

    for (int i = 0; i < n; i ++) {
        int u, k;
        std::cin >> u >> k;
        for (int j = 0; j < k; j ++) {
            int a;
            std::cin >> a;
            Adj[u][a] = 1;
        }
    }

    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= n; j ++) {
            if (j > 1) std::cout << " ";
            std::cout << Adj[i][j];
        }
        std::cout << std::endl;
    }
}



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

public class Main {
	public static void main(String[] args) throws IOException{
		final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		
		for(int i=0;i<n;i++){
			int line = 0;
			String str1=br.readLine();
			String str2=br.readLine();
			int[][] x=new int[str1.length()+1][str2.length()+1];
			//str1=" "+str1;
			//str2=" "+str2;	
			for(int j=1;j<=str1.length();j++){
				for(int k=1;k<=str2.length();k++){
					char a=str1.charAt(j-1);
					char b=str2.charAt(k-1);
					if(a==b) x[j][k]=x[j-1][k-1]+1;
					else x[j][k]=Math.max(x[j-1][k],x[j][k-1] );
					line=Math.max(line, x[j][k]);
				}
				
			}
			System.out.println(line);
		}
		br.close();
	}
}

Measured memory_bytes: 59356
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
const long long INF=1e18;
int main(){
	int n;
	cin>>n;
	ll ans=1,temp;
	int flag=0;
	for(int i=0;i<n;i++){
		cin>>temp;
		if(temp==0){
			flag=1;
		}
		if(flag==1)	continue;
		if(INF/temp<ans)
			flag=-1;
		ans*=temp;
	}
	if(flag==1)	puts("0");
	else if(flag==-1)	puts("-1");
	else	cout<<ans<<endl;
	return 0;
} 


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

int main()
{
    int n,limit;
    cin>>n>>limit;
    int eligible;
    for(int i=0;i<n;++i){
        int p;
        scanf("%d",&p);
        if(p>=limit) eligible++; 
    }
    cout<<eligible;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	vector<int>a(n);
	for(int &i:a)cin>>i;
	sort(a.rbegin(),a.rend());
	long long ans=0;
	for(int i=1;i<n;i++)ans+=a[i/2];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    
    int N;
    string S;
    cin >> N >> S;
    
    int nB = 0, nW = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == '.') ++nW;
        else ++nB;
    }
    
    int nRes = nW;
    int nBTmp = 0, nWTmp = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == '.') ++nWTmp;
        else ++nBTmp;
        
        int n = (i+1-nWTmp) + (N-1-i-nB+nBTmp);
        if (n < nRes) nRes = n;
    }
    
    cout << nRes << endl;

    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
using namespace std;
struct leprechaun
{
    int id;
    string name;
    int score;
};
leprechaun chtholly[110];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> chtholly[i].name >> chtholly[i].score, chtholly[i].id=i;
    sort(chtholly+1, chtholly+n+1,[](leprechaun a, leprechaun b)
    {
        if (a.name == b.name)return a.score > b.score;
        else return a.name < b.name;
    });
    for (int i = 1; i <= n; i++)cout << chtholly[i].id << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;

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

      int n,k; cin >> n >> k;
      vector<int> a(n);
      rep(i,k){
          int d; cin >> d;
          rep(i,d){
              int A; cin >> A;
              A--;
              a[A]++;
          }
      }

      int ans = 0;
      rep(i,n){
          if(a[i]==0) ans++;
      }

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


Measured memory_bytes: 3664
# -*- coding: utf-8 -*-

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

# 最も家と家の間の距離が大きい長さ（max_distance）を求め、K - max_distanceを求める

max_distance = A[0] + (K - A[-1])
for i in range(len(A) - 1):
    dis = A[i + 1] - A[i]
    max_distance = max(max_distance, dis)

ans = K - max_distance
print(ans)

Measured memory_bytes: 26444
def main():
    import sys
    input = sys.stdin.readline
    
    m, d = map(int, input().split())
    
    ans = 0
    for i in range(1, m + 1):
        for j in range(1, d + 1):
            a = j % 10
            b = j // 10
            if a >= 2 and b >= 2 and a * b == i:
                ans += 1
    
    print(ans)
    
    return 0

main()

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

#define ll  long long int
#define ld  long double
#define MAX 1000001
#define MOD 1000000007
#define pi  3.14159265358979323846264338
#define mp  make_pair
#define pb  push_back
#define pll pair<ll,ll>
#define vl  vector<ll>
#define vi  vector<int>
#define vs  vector<string>
#define vc  vector<char>
#define fst first
#define sec second
#define foi(i, a, b)   for(ll i = a; i<b;i++)
#define fod(i, a, b)   for(ll i = a;i>=b;i--)
#define all(v)         (v).begin(), (v).end()
#define max3(a, b, c)  max(max(a,b), c)
#define min3(a, b, c)  min(min(a,b), c)
#define ump  unordered_map<ll,ll>
#define us   unordered_set<ll>
#define nl  "\n"
#define INF  (ll)1e18
#define s(v) (ll)(v).size()
#define e(v) (v).empty

using namespace std;

ll gcd(ll a,ll b) { if (a==0) return b; return gcd(b%a,a);}


void solve(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    foi(i,0,n) cin>>h[i];
    vector<int> dp(n,INT_MAX);
    dp[0] = 0;
    foi(i,1,min(k+1,n)){
        dp[i] = abs(h[0]-h[i]);
    }
    
    foi(i,k+1,n){
        for(int j=1;j<=k;j++){
            dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]));    
        }
        //dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]) , dp[i-2] + abs(h[i]-h[i-2]) );
    }
    cout<<dp[n-1]<<"\n";
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3980
object Main {
  import scala.io.StdIn._
  import scala.annotation.tailrec
  import scala.collection.mutable.Queue
  def main(args: Array[String]): Unit = {
    var lunlunQueue = Queue((1 to 9).map(_.toString):_*)
    var k = readLine().toInt
    @tailrec
    def loop(i: Int): Unit =
      if (i == 1) println(lunlunQueue.head)
      else {
        val h = lunlunQueue.dequeue()
        val l = Character.digit(h.last, 10)
        for {
          i <- Seq(l - 1, l, l + 1)
          if i >= 0 && i < 10
        } {
          lunlunQueue.enqueue(h + (i))
        }
        loop(i - 1)
      }
    loop(k)
  }
}


Measured memory_bytes: 103112