akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      s: chars,
    }
    let n = s.len();
    let max = 1 << (n-1);
    let mut ans = 0;
    for bit in 0..max {
        let mut nums = vec![];
        let mut cur = vec![];
        cur.push(s[0]);

        for i in 1..n {
            if bit & (1 << (i-1)) > 0 {
                nums.push(cur);
                cur = vec![];
            }
            cur.push(s[i]);
        }
        nums.push(cur);
        for cs in nums.into_iter() {
            let s = cs.into_iter().collect::<String>();
            ans += s.parse::<u64>().unwrap();
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;

int main(){
  int n, k;
  cin >> n >> k;
  int a[n];
  rep(i,n) cin >> a[i];
  int l = 0;
  vector<int> u(n+1);
  int num = 0;
  int r = 0;
  int ans = INF;
  rep(l,n) {
    while(r < n && num < k) {
      if(u[a[r]] == 0 && a[r] <= k) num++;
      u[a[r]]++;
      r++;
    }
    if(num == k) ans = min(ans,r-l);
    if(u[a[l]] == 1 && a[l] <= k) num--;
    u[a[l]]--;
  }
  cout << (ans == INF ? 0 : ans) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
using namespace std;
typedef pair< int , int > P;
#define fr first
#define sc second

int main(){
  int N;
  P pt[100];
  cin >> N;
  for(int i = 0 ; i < N ; i++ ) pt[i].sc = i,pt[i].fr = 0;
  for(int i = 0 ; i < N * (N - 1) / 2 ; i++ ){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(c > d) pt[a-1].fr += 3;
    else if(c < d) pt[b-1].fr += 3;
    else pt[a-1].fr++, pt[b-1].fr++;
  }
  int ANSER[N],cnt = 2;
  sort(pt,pt+N,greater<P>());
  ANSER[pt[0].sc] = 1;
  for(int i = 1, flg = 2 ; i < N ; i++ ){
    if(pt[i].fr == pt[i-1].fr) cnt--;
    else cnt = flg;
    ANSER[pt[i].sc] = cnt;
    cnt++, flg++;
  }
  for(int i = 0 ; i < N ; i++ ) cout << ANSER[i] << endl;
}

Measured memory_bytes: 1164
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main(){
	auto F=readln.split.to!(int[]),A=F[0],B=F[1],C=F[2];
	if(A+B+C==17)writeln("YES");
	else writeln("NO");

}

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

using namespace std;

int main(void)
{
    int H, W;
    cin >> H >> W;
    vector<string> v(H);
    for(auto& e : v)
        cin >> e;
    for(auto& e : v)
    {
        cout << e << endl;
        cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int A, B;
  cin >> A >> B;
  int ans = max(0, A - B * 2);
  cout << ans << endl;
}


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

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	ll x, cnt; cin >> x;
	cnt = x / 11;
	x = x - cnt * 11;
	cnt = cnt * 2;
	if (x > 6) cnt += 2;
	else if (x > 0) cnt += 1;
	cout << cnt; 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    Point[][] map;
    int[][] route;
    int w, h;
    int x, y;
    LinkedList<int[]> que;
    // r, l, d, u
    int[] dirX = { 1, -1, 0, 0 };
    int[] dirY = { 0, 0, 1, -1 };

    void run(){
	while(sc.hasNext()){
	    w = sc.nextInt();
	    h = sc.nextInt();
	    if(w==0 && h==0) break;
	    map = new Point[h][w];
	    route = new int[h][w];
	    for(int i=0; i<h; i++)
		Arrays.fill(route[i], Integer.MAX_VALUE);
	    putMap();
	
	    solve();
	    System.out.println( route[h-1][w-1]!=Integer.MAX_VALUE
				? route[h-1][w-1] : "0");
	}
    }

    boolean solve(){
	que = new LinkedList<int[]>();
	x = 0; y = 0;
	route[0][0] = 1;
	search(x, y);
	while(!que.isEmpty()){
	    int[] p = que.pollFirst();
	    if(p[0]==w-1 && p[1]==h-1) return true;
	    search(p[0], p[1]);
	}
	return false;
    }

    void search(int x, int y){
	//map[y][x].show();
	if(map[y][x].isVisit()) return;
	map[y][x].visited();
	for(int i=0; i<4; i++){
	    if(!map[y][x].isWall(i)){
		int[] a = { x+dirX[i], y+dirY[i] };
		route[a[1]][a[0]] = Math.min(route[a[1]][a[0]], route[y][x]+1);
		if(!map[a[1]][a[0]].isVisit()) que.add(a);
	    }
	}
    }

    void putMap(){
	// 初期設定
	for(int i=0; i<h; i++)
	    for(int k=0; k<w; k++){
		map[i][k] = new Point(k, i);
		if(i==0) map[i][k].makeWall(3);
		if(i==h-1) map[i][k].makeWall(2);
		if(k==w-1) map[i][k].makeWall(0);
		if(k==0) map[i][k].makeWall(1);
	    }

	// 壁作成
	int a=0, b;
	for(int i=0; i<2*h-1; i++){
	    b = 0;
	    for(int k=0; k<w-1+(i%2); k++){
		if(sc.nextInt()==1){
		    // 横の壁
		    if(i%2==0){
			map[a][b].makeWall(0);
			if(b+1<w)
			    map[a][b+1].makeWall(1);
		    }
		    // 縦の壁
		    else{
			map[a][b].makeWall(2);
			if(a+1<h)
			    map[a+1][b].makeWall(3);
		    }
		}
		b++;
	    }
	    if(i%2==1) a++;
	}
    }
}    

class Point{
    int x, y;
    boolean[] dir; // r, l, d, u;
    boolean visit;

    Point(int a, int b){
	x = a;  y = b;  visit = false;
	dir = new boolean[4];
    }

    void makeWall(int d){ dir[d] = true; } 
    void visited(){ visit = true; } 
   
    boolean isVisit(){ return visit; }
    boolean isWall(int i){ return dir[i]; }

    void show(){
	System.out.print
	    ("----------\n"+x+" "+y+"\n");
	for(int i=0; i<4; i++)
	    System.out.print(dir[i]+" ");
	System.out.println("\n-----------");
    }
}

Measured memory_bytes: 69228
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += lower_bound(ALL(L), L[i] + L[j]) - L.begin() - j - 1;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int n, l;
    vector<string> s(100);
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for (auto it = s.begin(); it != s.end(); ++it) {
        cout << *it;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
MOD = 10**9+7

m = 1
a,b = [],[]
while m*m <= N:
    a.append(m)
    b.append(N//m)
    m += 1
if a[-1] == b[-1]:
    b.pop()
a += b[::-1]
w = [b-a for a,b in zip([0]+a, a)]

L = len(a)
dp = [1]*L
for _ in range(K-1):
    dp2 = [0]*L
    c = 0
    for i,v in enumerate(w):
        c += dp[i] * v
        dp2[L-1-i] += c
        dp2[L-1-i] %= MOD
    dp = dp2
ans = sum(a*b for a,b in zip(w,dp))
print(ans%MOD)

Measured memory_bytes: 76316
### ref:https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M = map(int, input().split())
    uni = UnionFind(N)
    for _ in range(M):
        x, y, z = map(int, input().split())
        x, y = x-1, y-1
        uni.union(x, y)
    print(uni.group_count())
main()

Measured memory_bytes: 7856
#include<stdio.h>
#include<math.h>

int main(){
    long int N;
    long int ans=0;
    long int i;
    long int top, down;
    long int sqr, tmp;

    scanf("%ld", &N);
    sqr = (int)sqrt(N);

    for(i=1; i<=sqr; i++){
        if(N%i == 0){
            if(i-1>0){
                if((N/(i-1)) == N%(i-1)){
                    ans += (i-1);
                }
            } 
            tmp = N/i;
            if(tmp-1>0){
                if((N/(tmp-1)) == N%(tmp-1)){
                    ans += (tmp-1);
                }
            }
        }
    }
    printf("%ld", ans);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int a[101][101],b[101],c[101];
    int i,j;
    int n,m;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++) {
        for (j=0;j<m;j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    for (i=0;i<n;i++) {
        c[i]=0;
        for(j=0;j<m;j++){
            c[i]=a[i][j]*b[j]+c[i];
        }
    }
    for (i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int n;
	vvp g;
	vl DIJ(int s){
		priority_queue<pll> q;
		vl d(n,INF);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			pll p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<g[v].size();i++){
				ll F=g[v][i].first,S=g[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					q.push({-d[F],F});
				}
			}
		}
		return d;
	}
	public:
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
	vl f(int v,ll D){
		vl d=DIJ(v),dp(n);
		dp[v]++;
		vpll a(n);
		for(int i=0;i<n;i++) a[i]={d[i],i};
		sort(a.begin(),a.end());
		for(int i=0;i<n;i++){
			int v=a[i].second;
			for(int j=0;j<g[v].size();j++){
				int u=g[v][j].first,c=g[v][j].second;
				if(d[v]==d[u]+c) (dp[v]+=dp[u])%=mod;
			}
		}
		for(int i=0;i<n;i++) dp[i]=dp[i]*dp[i]%mod;
		return dp;
	}
	ll solve(int s,int t){
		vl d=DIJ(s),d_=DIJ(t);
		ll D=d[t];
		vl a=f(s,D),b=f(t,D);
		ll res=0,sum=a[t];
		double D2=(double)D/2;
		for(int i=0;i<n;i++) if(D%2==0&&D/2==d[i]) (res+=a[i]*b[i])%=mod;
		for(int v=0;v<n;v++) for(int j=0;j<g[v].size();j++){
			int u=g[v][j].first,c=g[v][j].second;
			if((double)d[v]<D2&&D2<(double)d[u]&&d[v]+d_[u]+c==D){
				(res+=a[v]*b[u])%=mod;
			}
		}
		res=(sum-res+mod)%mod;
		return res;
	}
};

int n,m,u,v;

int main(){
	cin>>n>>m>>u>>v;
	Graph g(n);
	for(int i=0;i<m;i++){
		int s,t,c;
		cin>>s>>t>>c;
		g.add_edge(s-1,t-1,c);
	}
	cout<<g.solve(u-1,v-1)<<endl;
}

Measured memory_bytes: 15124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
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;}

const ll LIM=1e4;
const ll MA=1e5;
const ll INF=1e10;
vector<ll> s_prime;
vector<ll> b_prime;
bool isPrime[MA+10];

void init(){
    rep(i,MA) isPrime[i]=true;
    isPrime[0]=false;isPrime[1]=false;
    for(ll i=2;i<=MA;i++){
        if(isPrime[i]==false) continue;
        for(ll j=2;i*j<=MA;j++) isPrime[i*j]=false;
    }

    for(int i=2;i<=MA;i++){
        if(isPrime[i]){
            if(i<=LIM) s_prime.push_back(i);
            else b_prime.push_back(i);
        }
    }
}

ll inverse(ll val){
    ll res=1;
    for(ll i=2;i<=100;i++){
        if(isPrime[i]==false) continue;
        int cnt=0;
        while(val%i==0){
            val/=i;
            cnt++;
        }
        cnt%=3;
        if(cnt==0) continue;
        while(cnt<3){
            cnt++;
            res*=i;
        }
    }
    return res;
}

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

    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];

    init();

    vector<ll> B(N);
    rep(i,N){
        ll val=A[i];
        for(auto d:s_prime){
            ll div=d*d*d;
            while(val%div==0) val/=div;
        }
        B[i]=val;
    }

    map<ll,int> mp;
    rep(i,N) mp[B[i]]++;

    ll ans=0;
    if(mp.count(1)){
        ans++;
        mp.erase(1);
    }

    for(auto d:b_prime){
        ll div=d*d;
        for(ll j=1;div*j<=INF;j++){
            if(mp.count(div*j)==false) continue;
            ll iv=inverse(j);
            ll tar=d*iv;
            if(mp.count(tar)){
                ans+=max(mp[tar],mp[div*j]);
                mp.erase(tar);
            }else ans+=mp[div*j];
            mp.erase(div*j);
        }
    }

    rep(i,N){
        if(mp.count(B[i])==false) continue;
        ll val=B[i];
        ll tar=1;
        for(auto d:s_prime){
            int cnt=0;
            while(val%d==0){
                cnt++;
                val/=d;
            }
            if(cnt==0) continue;
            while(cnt<3){
                cnt++;
                tar*=d;
            }
        }

        if(val!=1) ans+=mp[B[i]];
        else{
            if(mp.count(tar)){
                ans+=max(mp[tar],mp[B[i]]);
                mp.erase(tar);
            }else ans+=max(mp[tar],mp[B[i]]);
        }
        mp.erase(B[i]);
    }

    cout<<ans<<endl;


    return 0;
}


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

int func(int N){
  if(N%2==0){
    return N/2;
  }
  else{
    return 3*N+1;
  }
}

int main(){
  int S;
  cin >> S;
  vector<int> A(100000000);
  A.at(0)=S;
  for(int i=1;i<10000000;i++){
    A.at(i)=func(A.at(i-1));
  }
  bool a=false;
  for(int i=0;i<10000000;i++){
    for(int j=i+1;j<10000000;j++){
      if(A.at(i)==A.at(j)){
        cout << j+1 << endl;
        a=true;
        break;
      }
    }
    if(a){
      break;
    }
  }
}  

Measured memory_bytes: 393980
#include <stdio.h>

static const int N=1000;

void trace(int *A, int n) {
    int i;

    for (i=0; i<n; i++) {
        if (i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void sort(int *A, int n) {
    int i, j, tmp;

    for (i=0;i<n;i++) {
        for (j=i+1;j<n;j++) {
            if (A[j]<A[i]) {
                tmp=A[i];
                A[i]=A[j];
                A[j]=tmp;
            }
        }
    }
}

int main(void) {
    int n, i;
    int A[N+1];

    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);

    //trace(A, n);
    for (i=1; i<=n; i++) sort(A, i), trace(A, n);

    return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <cmath>
#include <climits>
#include <set>
#include <unordered_set>
#define  endl "\n"
using namespace std;

void FastInput() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void OutputFile(){freopen("output.txt","w",stdout);}



int main()
{

   FastInput();

    int k;
    string s;
    cin>>k>>s;
    if(s.length()<=k)
        cout<<s;
    else
    {
        cout<<s.substr(0,k)+"...";
    }

   return 0;
}



Measured memory_bytes: 3680
package main

import (
	"fmt"
)

// go run ./main.go < in

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	ok := false
	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			sum := i*10000 + j*5000 + (n-i-j)*1000
			if sum == y {
				ok = true
				fmt.Println(i, j, n-i-j)
				break
			}
		}
		if ok {
			break
		}
	}
	if !ok {
		fmt.Println(-1, -1, -1)
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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



int m, b[200005];
int tmp[200005];
VI vec;

int main() {

	cin >> m;
	rrep(i, m)cin >> b[i];


	for (int i = m; i >= 1; i--) {
		for (int j = 2; j * i <= m; j++) {
			tmp[i] += tmp[j * i];
		}
		if (tmp[i] % 2 != b[i]) {
			tmp[i] = 1;
			vec.push_back(i);
		}
		else {
			tmp[i] = 0;
		}
	}

	sort(all(vec));


	cout << vec.size() << endl;
	rep(i, vec.size()) {
		cout << vec[i] << endl;
	}

	return 0;
}


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

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

        while(a.size()>1){
                vector<int> b;
                for(int i=0;i<a.size();i+=2){
                        if(a[i]==a[i+1]) b.push_back(a[i]);
                        else b.push_back(max(a[i],a[i+1])-min(a[i],a[i+1]));
                }
                a=b;
        }
        cout<<a[0]<<endl;
        return 0;
}


Measured memory_bytes: 1916
from collections import Counter
n = int( input())
V = list( map( int, input().split()))
oddV = [ V[2*i+1] for i in range(n//2)]
evenV = [ V[2*i] for i in range(n//2)]
CoddV = Counter(oddV).most_common()
CevenV = Counter(evenV).most_common()
p, q = CoddV[0]
a, b = CevenV[0]
if p != a:
    ans = n-b-q
elif n == 2:
    ans = 1
else:
    if q == n//2 and b == n//2:
        ans = n//2
    elif q == n//2:
        ans = n//2 - CevenV[1][1]
    elif b == n//2:
        ans = n//2 - CoddV[1][1]
    else:
        r, s = CoddV[1]
        c, d = CevenV[1]
        if q + d >= s + b:
            ans = n-q-d
        else:
            ans = n-s-b
print(ans)

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

const int MAXN = 1e5 + 10;
int a[MAXN];

int main(void){
    int n, sol = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(a[i] == i){
            cnt++;
        }else{
            sol += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    sol += (cnt + 1) / 2;
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 640
import math
n = int(input())
X = sorted(list(map(int, input().split())))
start = X[0]
end = X[-1]

ans = 10000000
for i in range(start, end+1):
    tmp = sum([(x-i)**2 for x in X])
    ans = min(tmp,ans) 
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll s,w;cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout<<"safe";
    return 0;  
} 





Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

const int MAX_W = 1024;
int dp[MAX_W];

int main()
{
  for (int tno = 1;; ++tno) {
      int W, N; scanf("%d%d", &W, &N);
      if (W == 0) break;

      memset(dp, 0, sizeof(dp));
      while (N--) {
          int w, v; scanf("%d, %d", &v, &w);
          for (int i = W; i - w >= 0; i--) {
              dp[i] = max(dp[i], dp[i - w] + v);
          }
      }
      int ans = 0;
      for (int i = 0; i <= W; i++) {
          if (dp[ans] < dp[i])
              ans = i;
      }
      printf("Case %d:\n", tno);
      printf("%d\n%d\n", dp[ans], ans);

  }
}

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

int abs(int a)
{
    if(a<0) a = -a;
    return a;
}

int main()
{
    int n,sum=0;
    int a[100000];
    cin >> n;
    for(int i=0;i<=n;i++){
        if(i==n){
            sum+=abs(a[n-1]);
        }else if(i==0){
            cin >> a[i];
            sum+=abs(a[i]);
        }else{
            cin >> a[i];
            sum+=abs(a[i]-a[i-1]);
        }
    }
    for(int i=0;i<n;i++){
        if(i==0){
            cout << sum-abs(a[0])-abs(a[0]-a[1])+abs(a[1]) << endl;
        }else if(i==n-1){
            cout << sum-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2]) << endl;
        }else{
            cout << sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]) << endl;
        }
    }
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct DisjointSet{
    vector<int> p;
    DisjointSet(int n) : p(n){
        rep(i,n) p[i] = -1;
    }

    int root(int x){
        if(p[x]<0) return x;
        return p[x] = root(p[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(rx>ry) swap(rx,ry);
        p[rx] += p[ry];
        p[ry] = rx;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, m; cin >> n >> m;
    DisjointSet dis = DisjointSet(n);
    rep(i,m){
        int ai, bi; cin >> ai >> bi;
        --ai, --bi;
        dis.unite(ai,bi);
    }
    set<int> s;

    rep(i,n){
        s.insert(dis.root(i));
    }

    int ans = s.size();
    --ans;

    cout << ans << endl;
}

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

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

    auto stones = vector<int>(N);
    for (auto& x : stones) cin >> x;

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    const function<bool(int, int)> dfs = [&](const int v, const int parent)
    {
        if (adjacency_list[v].size() == 1) return true;

        auto sum = 0LL;
        auto max = 0;
        for (auto child : adjacency_list[v]) if (child != parent)
        {
            if (!dfs(child, v)) return false;
            sum += stones[child];
            max = std::max(max, stones[child]);
        }

        const auto internal = sum - stones[v], external = 2*stones[v] - sum;
        stones[v] = int(external);
        const auto bound = max >= sum-max ? sum-max : sum/2;
        return 0 <= internal && internal <= bound && 0 <= external;
    };

    if (N == 2)
    {
        cout << (stones[0] == stones[1] ? "YES" : "NO") << endl;
    }
    else
    {
        auto root = 0;
        while (adjacency_list[root].size() == 1) root++;
        cout << (dfs(root, -1) && stones[root] == 0 ? "YES" : "NO") << endl;
    }
}


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

using namespace std;

int main()
{
	double a, b, x;
	cin >> a >> b >> x;
	double full = a * a * b;
	double half = full / 2.0;
	if (half <= x) {
		double height = (full - x) / (a * a) * 2;
		double theta = atan(height / a) * 180 / M_PI;
		printf("%.10f\n", theta);
	} else {
		double height = x / (a * b) * 2;
		double theta = (M_PI / 2 - atan(height / b)) * 180 / M_PI;
		printf("%.10f\n", theta);
	}

	return 0;
}


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

int main()
{
    int a,b,c,d,i;
    cin>>a>>b>>c;
    int arr[a+10];
    for(i=1; i<=a; i++)
    {
        arr[i]=0;
    }
    for(i=0; i<c; i++)
    {
        cin>>d;
        arr[d]++;
    }
    for(i=1; i<=a; i++)
    {
        if(b-(c-arr[i])>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;

template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<998244353>;

mint my_pow(ll a,ll b){
	if(b == 0)return 1;
	if(b%2 == 0){
		mint t = my_pow(a,b/2);
		return t * t;
	}
	return (mint)a * my_pow(a,b - 1);
}

signed main(){
	//cout << fixed << setprecision(10);
	ll n; cin >> n;
	vl a(n);
	rep(i,0,n)cin >> a[i];
	if(a[0] != 0){
		cout << 0 << endl;
		return 0;
	}
	vl dep(n);
	rep(i,0,n){
		dep[a[i]]++;
	}
	if(dep[0] > 1){
		cout << 0 << endl;
		return 0;
	}
	mint ans = 1;
	rep(i,1,n){
		ans *= my_pow(dep[i-1], dep[i]);
	}
	cout << ans << endl;
		


	return 0;
}

Measured memory_bytes: 4736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	vector<LL> a(n);

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

	LL tmp = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			tmp += a[i];
		}
		else {
			tmp -= a[i];
		}
	}

	vector<LL> ans(n);
	ans[0] = tmp;

	for (int i = 1; i < n; i++) {
		tmp = -tmp;
		tmp += (a[i - 1] * 2);

		ans[i] = tmp;
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i];

		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}

}

Measured memory_bytes: 2944
import java.util.*;
import java.lang.*;
public class Main { public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		// radius 半径
		double radius = sc.nextDouble(); 
		// 面積 = 半径 * 半径 * Pi
		double area = radius * radius * Math.PI; 
		// 円周 = 直径 * Pi 
		double leng = (radius *2)* Math.PI;
	
		//System.out.println(area + " " + leng); 
		System.out.println(String.format("%.6f %.6f\n",area,leng));
	}
} 


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

template <typename T> vector<T> slide_min(const vector<T> &v, int k) {
    deque<int> deq;
    vector<int> res;
    for (int i = 0; i < v.size(); ++i) {
        while (!deq.empty() && v[deq.back()] >= v[i]) {
            deq.pop_back();
        }
        deq.push_back(i);
        if (i - k + 1 >= 0) {
            res.emplace_back(v[deq.front()]);
            if (deq.front() == i - k + 1) deq.pop_front();
        }
    }
    return res;
}

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    auto v = slide_min(a, L);
    for (int i = 0; i < v.size(); ++i) {
        cout << v[i] << " \n"[i + 1 == v.size()];
    }
}


Measured memory_bytes: 11004
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x.begin(),x.end())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define endl "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define sz(a) (int)a.size()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define Q(x) for(int i=0;i<x;i++)
#define show(x) for(auto i:x)cout<<i<<" ";cout<<endl;

using namespace std;
const ll mod = 1e9 + 7;

int main() {

	ll n;
	cin >> n;
	vll a(n);
	Q(n)cin >> a[i];
	vll ps(n);
	ps[0] = a[0];
	rep(i, 1, n) {
		ps[i] = (ps[i - 1] + a[i]) ;
	}
	ll ans = 0;
	rep(i, 0, n - 1) {
		ans += ((a[i] * ((ps[n - 1] - ps[i]) % mod))  % mod);
	}
	ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int K;
string S;

int main() {
    cin >> K >> S;

    if (S.length() <= K) cout << S << endl;
    else cout << S.substr(0, K) << "..." << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, k, c; cin >> n >> k >> c;
    string s; cin >> s;
    
    ll noruma[n]; memset(noruma, -1, sizeof(noruma));
    ll b = -INF;
    ll at = 0;
    zep(i, 0, n){
    	if(s[i] == 'o' && i-b-1 >= c){
    		at++;
    		noruma[i] = at;
    		b = i;
    	}
    }
    if(at > k){return 0;}
    
    b = INF;
    bool fix = false;
    at = k;
    rrep(i, n-1, 0){
    	if(s[i] == 'o'){
			if(noruma[i] < 0){
				if(b-i-1 >= c){
					noruma[i] = at;
					if(!fix){
						b = i;
						fix = true;
					}
				}
			}
			else{
				if(!fix){b = i;}
				fix = false;
				at--;
			}
    	}
    }
    //printa(noruma, 0, n-1)
    
    ll cnt[k+1]; memset(cnt, 0, sizeof(cnt));
    zep(i, 0, n){
    	if(noruma[i] > 0){
    		cnt[noruma[i]]++;
    	}
    }
    
    zep(i, 0, n){
    	if(noruma[i] > 0 && cnt[noruma[i]] == 1){
    		print(i+1)
    	}
    }
    
    return 0;
}

Measured memory_bytes: 5012
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<a[n-1]<<flush;
    for(int i=1;i<(n+1)/2;i++){
        cout<<' '<<a[n-1-2*i]<<flush;
    }
    for(int i=0;i<n/2;i++){
        cout<<' '<<a[2*i+(n%2)]<<flush;
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 7136
if __name__ == "__main__":

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

    s = [0] * n * m

    for c in xrange(n):
        s[c*m:c*m+m] = map( int, raw_input().split())

    csum = [0] * n
    rsum = [0] * m
    for c in xrange(n):
        for r in xrange(m):
            csum[c] += s[m*c + r]
            rsum[r] += s[m*c + r]
            print s[m*c + r],
        print csum[c]
    asum = 0
    for i in xrange(m):
        asum += rsum[i]
        print rsum[i],
    print asum

Measured memory_bytes: 4308
import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a /= 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[222222];

int X[222222],S[222222];


signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N){
        X[i+1]=X[i]^A[i];
        S[i+1]=S[i]+A[i];
    }

    int ans=0;
    rep(i,N){
        int lb=i,ub=N+1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if((X[mid]^X[i])==S[mid]-S[i])lb=mid;
            else ub=mid;
        }
        ans+=lb-i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5248
let solve n ar =
  let rec inner ans tmp i =
    if i = n then (tmp + ans)
    else
      inner (ans + tmp) (ar.(i)) (i+1)
      |> (+) @@ inner (ans) (tmp * 10 + ar.(i)) (i+1)
  in inner 0 ar.(0) 1 

let _ =
  let temp = Scanf.scanf "%s\n" (fun s -> s) in
  let s = Array.make 10 0 in
  let n = String.length temp in
  for i = 0 to n - 1 do
    s.(i) <- String.get temp i |> (fun c -> Char.code c - Char.code '0')
  done;
  solve n s |> print_int

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);

		String line2 = sc.nextLine();
		String[] k = line2.split(" ");

		String[] k2 = new String[v];
		for (int i = 0; i < v; i++) {
			k2[i]=k[i];
		}

		for (int i = 0; i < v; i++) {
			for (int j = v - 1; j > 0; j--) {
				int key = j - 1;
				if (Card.sub(k[key]) > Card.sub(k[j])) {
					String a = k[key];
					String b = k[j];

					k[key] = b;
					k[j] = a;

				}
			}

		}

		for (int i = 0; i < v; i++) {
			int min = i;
			for (int j = i; j < v; j++) {
				if (Card.sub(k2[min]) > Card.sub(k2[j])) {
					min = j;
				}
				
			}if (min != i) {
					String c = k2[min];
					String d = k2[i];
					k2[min] = d;
					k2[i] = c;
				}
		}
		for (int i = 0; i < v; i++) {
			System.out.print(k[i]);
			if (i != v - 1) {
				System.out.print(" ");
			}
		}System.out.println("");
		System.out.println("Stable");
		
		for (int i = 0; i < v; i++) {
			System.out.print(k2[i]);
			if (i != v - 1) {
				System.out.print(" ");
			}
		}System.out.println("");
		int count=0;
		for (int i = 0; i < v; i++) {
			if(!(k[i].equals(k2[i]))){
				count++;
			}
		}if (count==0) {
			System.out.println("Stable");
		}else{
			System.out.println("Not stable");
		}
		}

	public static class Card {
		public static int sub(String k) {
			return Integer.parseInt(k.substring(1));
		}
	}

}

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


int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);
    set<int> st(vec.begin(), vec.end());
    cout << st.size() << endl;
    return 0;
}


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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;

        if (temp >= k) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
a,b,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
can = [min(x)+min(y)]
for _ in range(m):
  i,j,c = map(int,input().split())
  i -= 1
  j -= 1
  can.append(x[i]+y[j]-c)
print(min(can))

Measured memory_bytes: 18612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
vi arr[26];
bool f[26];
int find1(int c,int idx){
	int first=0,last=arr[c].size()-1;
	while(first<=last){
		int mid=(first+last)/2;
		// cout<<mid<<":"<<arr[c][mid]<<" ";
		if(arr[c][mid]<=idx)
			first=mid+1;
		else
			last=mid-1;
	}
	if(first==arr[c].size())
		return -1;
	else return arr[c][first];
}

bool  check(){
	bool is=false;
	for(int i=0;i<26;++i){
		// cout<<f[i]<<" ";
		is=is||f[i];
	}
	return is;
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	string s,t;
	cin>>s>>t;
	for(int i=0;i<t.size();++i){
		f[t[i]-'a']=true;
	}
	for(int i=0;i<s.size();++i){
		arr[s[i]-'a'].pb(i);
		f[s[i]-'a']=false;
	}
	if(check())
		cout<<-1<<endl;
	else{
		ll c=1;
		int curr=-1;
		for(int i=0;i<t.size();++i){
			int temp=find1(t[i]-'a',curr);
			// cout<<"->"<<temp<<" ";
			if(temp==-1){
				c++;
				curr=arr[t[i]-'a'][0];
			}
			else
				curr=temp;
			// cout<<curr<<endl;

		}
		cout<<c*s.size()-(s.size()-curr-1)<<endl;
	}


}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,n,a;
    cin>>h>>n;
    int sum=0;
    for (int i=0;i<n;i++){
        cin>>a;
        sum+=a;
    }
    if (sum>=h) cout<<"Yes";
    else cout<<"No";
}


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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501

using namespace std;

void quick ()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

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

int diva (int n)
{
    int counter = 0;
    for (int i = 1 ; i <= n ; i++)
    {
        if (n%i==0)
            counter++;
    }
    return counter;
}

void readFromText()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    quick();
//    readFromText();
    int n ;
    cin >> n;
    int arr[n];
    for (int i = 0 ; i < n ; i++)
        cin>>arr[i];
    int minV=INT_MAX,start=INT_MAX,endd=INT_MIN;
    for(int i=0; i<n; i++)
    {
        endd=max(endd,arr[i]);
        start=min(start,arr[i]);
    }
    for(int i=start; i<=endd; i++)
    {
        int cnt=0;
        for(int j=0; j<n; j++)
        {
            cnt+=abs(arr[j]-i)*abs(arr[j]-i);
        }
        minV = min(minV,cnt);
    }
    cout<< minV ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=3000;
int d[N], a[N], c[N], r[N], ans[N];
int p;

void prod() {
	d[1]=1;
	//  f(x)=sum di*x^i
	//  ff(x) = sum  di*x^(i+1) - d(i+1) 
	for (int i=1; i<p; i++) {
		for (int j=i+1; j>=1; j--) d[j]=(d[j-1]-i*d[j]%p+p)%p;
	//	for (int j=i+1; j>=1; j--) cout<<d[j]<<"x^"<<j<<"+";cout<<endl; 
	}
	for (int i=1; i<p; i++) d[i]=(d[i]%p+p)%p;
//	for (int i=p; i>=1; i--) cout<<d[i]<<"x^"<<i<<"+";
	//cout<<endl;
}

void div(int k) {
	//D / (x-k)
	for (int i=0; i<=p; i++) c[i]=d[i];
	for (int i=p; i>=1; i--) {
		c[i-1]=(c[i-1]+c[i]*k)%p;
	}
	for (int i=0; i<p; i++) ans[i]=(ans[i]+a[k]*c[i+1])%p;
//	if (c[0]!=0) cout<<"gg: "<<k<<endl;
//	for (int j=p; j>=0; j--) cout<<c[j]<<" ";cout<<endl;//<<"x^"<<j<<"+";cout<<endl; 
}
	
int main() {
	cin>>p;
	prod();
	//b[0]=a[0];
	//f(1)*1
	for (int i=0; i<p; i++) cin>>a[i];
	
	for (int i=1; i<p; i++)
	for (int j=1; j<p; j++) {
		if (i*j%p==1) r[i]=j;
	}
	
	for (int i=0; i<p; i++)
	for (int j=0; j<p; j++) {
		if (i!=j) a[i]=a[i]*r[(i-j+p)%p]%p;
	}
	
	
	for (int i=0; i<p; i++) div(i);
	for (int i=0; i<p; i++) cout<<ans[i]%p<<" ";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int[] p = new int[A];
    int[] q = new int[B];
    Queue<Integer> r = new PriorityQueue<>(Comparator.reverseOrder());
    for (int i = 0; i < A; i++) {
      p[i] = sc.nextInt();
    }
    for (int i = 0; i < B; i++) {
      q[i] = sc.nextInt();
    }
    for (int i = 0; i < C; i++) {
      r.add(sc.nextInt());
    }
    Arrays.sort(p);
    Queue<Integer> p1 = new PriorityQueue<>();
    Arrays.sort(q);
    Queue<Integer> q1 = new PriorityQueue<>();
    long ans = 0;
    for (int i = A - X; i < A; i++) {
      ans += p[i];
      p1.add(p[i]);
    }
    for (int i = B - Y; i < B; i++) {
      ans += q[i];
      q1.add(q[i]);
    }

    int a = A - X, b = B - Y;
    while (!r.isEmpty()) {
      int r1 = r.poll();
      int a1 = p1.peek();
      int b1 = q1.peek();
      if (a1 < b1) {
        if (r1 > a1) {
          ans -= a1;
          ans += r1;
          p1.poll();
          p1.add(r1);
        }
      } else {
        if (r1 > b1) {
          ans -= b1;
          ans += r1;
          q1.poll();
          q1.add(r1);
        }
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 93348
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int ans = 1;
    REP(i, n){
        if(i>=1){
            ans *= k-1;
        } else {
            ans *= k;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int d;
  cin >> d;

  cout << "Christmas";
  while (d ++ < 25)
  {
    cout << " Eve";
  }
  cout << endl;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}


Measured memory_bytes: 256