akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  long long sum = 0;
  vector<int> a(n + 1, 0);
  for(int i = 1; i <= n; i ++){
    cin >> a[i];
  }
  for(int i = 1; i <= n; i ++){
    for(int j = i + 1; j <= n; j ++){
      sum += (a[i] * a[j]);
    }
  }
  cout << sum << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, W, H; cin >> N >> W >> H;
	vector<int> yoko(W + 10, 0), tate(H + 10, 0);

	for (int i = 0; i < N;i++) {
		int x, y, w; cin >> x >> y >> w;
		yoko[max(0,x - w)]++; yoko[min(W+1,x + w)]--;
		tate[max(0,y - w)]++; tate[min(H+1,y + w)]--;
	}

	bool f = true;
	if (yoko[0] == 0) f = false;
	for (int i = 1; i < W;i++) {
		yoko[i] += yoko[i - 1];
		//cout << yoko[i] << endl;
		if (yoko[i] == 0) f = false;
	}
	if (f) { cout << "Yes" << endl; return 0; }
	f = true;
	if (tate[0] == 0)f = false;
	for (int i = 1; i < H;i++) {
		tate[i] += tate[i - 1];
		if (tate[i] == 0) f = false;
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3592
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits



def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

x, y = MAP()

print(int(x+y/2))

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define rep(i,a,b) for(i=a;i<b;i++)
#define hell 1000000007
#define mod 998244353
#define fs first
#define sc second
#define all(v) v.begin(),v.end()

int main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int n,i,j,sum=0;
  cin>>n;
  string s;
  cin>>s;
  rep(i,0,n)
  {
    j=i;
    while(s[j]==s[i] && i<n)
    {
      i++;
    }
    if(j<n)
      {
        sum++;
        i--;
      }
    else
      break;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
    int n;cin>>n;
    map<int,int> a;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(a.count(x)) a[x]++;
        else a[x]=1;
    }
    int cnt=0;
    for(auto p:a){

        if(p.second%2==1) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 4992
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

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

    int     S = 0;
    int     W = 0;
    cin >> S >> W;
    string  ans;

    if(W >= S){
        ans = "unsafe";
    }else{
        ans = "safe";
    }

    cout << ans << "\n";
    return 0;
    
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(void){
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    if(h>w){
        if(n%h==0){
            printf("%d",n/h);
        }else{
            printf("%d",(n/h)+1);
        }
    }else{
        if(n%w==0){
            printf("%d",n/w);
        }else{
            printf("%d",(n/w)+1);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	long long c[5] = {0};

	int N;
	cin >> N;

	string s;
	REP(i, N){
		cin >> s;
		if(s[0] == 'M')c[0]++;
		if(s[0] == 'A')c[1]++;
		if(s[0] == 'R')c[2]++;
		if(s[0] == 'C')c[3]++;
		if(s[0] == 'H')c[4]++;
	}

	long long count = 0;
	FOR(i, 0, 4 + 1){
		FOR(j, i + 1, 4 + 1){
			FOR(k, j + 1, 4 + 1){
				count += c[i] * c[j] * c[k];
			}
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;



signed main(){
	rep(i,5){
		int a;cin>>a;
		if(a==0){
			cout<<i+1<<endl;return 0;
		}
	}
}


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

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

    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0] )cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    int x;
    int c0;
    vector<int> a(n+1);
    vector<int> b(n+1,0);
    rep2(1,i,n+1){
        cin>>x;
        a[i]=x;
    }
    int m=0;
    for(int i=n;i>0;i--){
        int sum=0;
        for(int j=1;j*i<=n;j++){
            sum+=b[j*i];
        }
        if(a[i]==0 && sum%2==1)b[i]=1;
        else if(a[i]==1 && sum%2==0)b[i]=1;
        
        if(b[i]==1)m++;

    }
    cout<<m<<endl;
    rep2(1,i,n+1){
        if(b[i]!=0)cout<<i<<" ";
    }cout<<endl;
    
    return 0;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>

using namespace std;

struct limit
{
    int start,end;
} alice,bob;

int main()
{
    cin >> alice.start >> alice.end >> bob.start >> bob.end;
    if(alice.start<=bob.start)
    {
        if(bob.start>alice.end) printf("0\n");
        else if(bob.start<=alice.end&&bob.end>alice.end) printf("%d\n",alice.end-bob.start);
        else if(bob.start<=alice.end&&bob.end<=alice.end) printf("%d\n",bob.end-bob.start);
    }
    else
    {
        if(alice.start>bob.end) printf("0\n");
        else if(alice.start<=bob.end&&alice.end>bob.end) printf("%d\n",bob.end-alice.start);
        else if(alice.start<=bob.end&&alice.end<=bob.end) printf("%d\n",alice.end-alice.start);
    }
    return 0;
}


Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define mod 1000000007
  #define N 2005
  #define INF 1000000000000
  #define eps 1e-6
  #define int long long
  #define pie 3.1415926535897932384626433832795028

  int arr[N];
  int dp[N][N];
  // dp[l][r] means the maximum hapiness we can get if 
  // we put the r-l + 1 kids from l to r index

int32_t main()
{




    int n;
    cin >> n;
    vector<pair<int,int>>arr(n);

    for(int i = 0; i < n; i++)
    {
      cin >> arr[i].f;
      arr[i].s = i;
    }

    sort(all(arr));
    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j < n; j++)
      {
        int l = j;
        int r = j + i - 1;

        if(l == r)
        {
          dp[l][l] = max(dp[l][l],arr[i-1].f*abs(arr[i-1].s-l));
        }
        else
        {
          dp[l][r] = max({dp[l+1][r] + arr[i-1].f * abs(arr[i-1].s - l),dp[l][r-1] + arr[i-1].f * abs(arr[i-1].s - r),dp[l][r]});
        }
      }
    }

    cout << dp[0][n-1];

    return 0;
}

Measured memory_bytes: 35012
#include<cstdio>
#include<algorithm>
using namespace std;
char s[20];

int main()
{
	int ans=0,n=0,sum=0;
	scanf("%s",s);
	bool flag=true;
	for(int i=0;s[i];i++,n++)
	{
		sum+=s[i]-'0';
		if(s[i]!='9')
			flag=false;
	}
	if(flag)
	{
		printf("%d\n",n*9);
		return 0;
	}
	if(n==1)
	{
		printf("%s",s);
		return 0;
	}
	ans=s[0]-'0'-1;
	for(int i=1;s[i];i++)
		ans+=9;
	printf("%d\n",max(ans,sum));
	return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func sum(a []int) (x int) {
	for _, i := range a {
		x += i
	}
	return
}

func main() {
	a := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&a[i])
	}

	minOnesPlace := 1000000
	idx := -1
	for i, v := range a {
		if x := v % 10; x != 0 && x < minOnesPlace {
			minOnesPlace = x
			idx = i
		}
	}

	if idx == -1 { // すべての数字の1の位が0だった場合
		fmt.Println(sum(a))
		return
	}

	ans := 0
	for i, v := range a {
		if x := v % 10; x == 0 || i == idx {
			ans += v
		} else {
			ans += (v + 10 - x)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

csum = Array.new(n+1, 0)

n.times do |i|
    csum[i+1] = csum[i] + as[i]
end
n.times do |i|
    csum[i+1] = (csum[i+1] - (i+1))%k
end

ans = 0
hh = {}
for i in 0..n
    ci = csum[i]
    hh[ci] = 0 if hh[ci] == nil
    ans += hh[ci]
    hh[ci] += 1
    if i >= k-1
        cj = csum[i-k+1]
        hh[cj] -= 1
    end
end

#p csum
puts ans


Measured memory_bytes: 39340
n = int(input())
a = list(map(int, input().split()))
dist = abs(a[0])
for i in range(n-1):
    dist += abs(a[i+1]-a[i])
dist += abs(a[-1])
a.insert(0, 0)
a.append(0)
for i in range(1, n+1):
    print(dist - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]))


Measured memory_bytes: 14048
import java.util.Scanner;

public class Main {

   public static void main(String[] args) {
      int[] dish = new int[5];
      boolean[] t = new boolean[5];
      int max = 0;
      int min = 0;
      int time = 0;
      Scanner sc = new Scanner(System.in);
      //최대 최소 인덱스 구함
      for (int i = 0; i < dish.length; i++) {
         dish[i] = sc.nextInt();
         if(dish[i]%10==0)
            continue;
         max = dish[max]%10>dish[i]%10?max:i;
         min = dish[min]%10<dish[i]%10?min:i;
      }
      if(max == min){
         max = 0;
         min = 4;
      }
      t[max] = t[min] = true;
      
      time += (int)Math.ceil((double)dish[max]/10)*10;
      for (int i = 0; i < 5; i++) {
         if(!t[i])
            time += (int)Math.ceil((double)dish[i]/10)*10;
      }
      time += dish[min];
      
      System.out.println(time);
   }

}

Measured memory_bytes: 20820
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstring>
#include<vector>
#define pii pair<int, int>
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define debug puts("???");
#define br puts("")
#define ALL(x) x.begin(),x.end()
#define sc(x) scanf("%d", &x)
#define sz(x) int((x).size())
using namespace std;
typedef long long LL;
const LL INF64 = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;

const int maxn = 1e5+10;

int n, a[maxn], cnt[2][maxn];
vector<pii> vp[2];

int main(){
    sc(n);
    for(int i = 1; i <= n; i++){
        sc(a[i]);
        cnt[i%2][a[i]]++;
    }
    for(int i = 0; i < maxn; i++) for(int j = 0; j < 2; j++){
        if(cnt[j][i]>0){
            vp[j].pb(mk(cnt[j][i],i));
        }
    }
    int s1 = (n+1)/2, s0 = n/2;
    sort(ALL(vp[0])); sort(ALL(vp[1]));
    int sz0 = vp[0].size(), sz1 = vp[1].size();
    if(vp[0].back().se==vp[1].back().se){
        if(sz0==1 && sz1 ==1){
            cout << n/2 << endl;
        }else if(sz0==1) cout << s1+s0-vp[0][0].fi-vp[1][sz1-2].fi<<endl;
        else if(sz1==1) cout << s1+s1-vp[1][0].fi-vp[0][sz0-2].fi<<endl;
        else{
            int ans = s1+s0-vp[0][sz0-1].fi-vp[1][sz1-2].fi;
            ans = min(ans,s1+s0-vp[0][sz0-2].fi-vp[1][sz1-1].fi);
            cout << ans << endl;
        }
    }else{
        cout << s1+s0-vp[1].back().fi-vp[0].back().fi<<endl;
    }
    return 0;
}


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



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

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, T, A;
	cin >> N >> T >> A;
	int ansnumber;
	double ans = INF;
	for (int i = 0; i < N; ++i) {
		double H;
		cin >> H;
		double t, d;
		t = T -H* 6 / 1000;
		d = fabs(A - t);
		if (d < ans) {
			ansnumber = i;
			ans = d;
		}
	}
	cout << ansnumber+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define PP pair<P,int>
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




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

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

UG es;
int dp[110000];
int da[110000];

void dfs(int v,int d,int c){
  if(dp[v]==0)
    dp[v]=c;
  if(da[v]>=d||d==0) return;
  da[v]=d;

  for(auto e:es[v]){
    dfs(e,d-1,c);
  }
}

main(){
  int n,m;
  cin>>n>>m;
  es.resize(n+1);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    es[a].PB(b);
    es[b].PB(a);
  }
  int q;
  cin>>q;

  vector<PP> v;
  rep(i,q){
    int a,b,c;
    cin>>a>>b>>c;
    v.PB(PP(P(a,b),c));
  }
  reverse(all(v));
  
  rep(i,q){
    dfs(v[i].F.F,v[i].F.S,v[i].S);
  }

  FOR(i,1,n+1){
    cout<<dp[i]<<endl;
  }

}


Measured memory_bytes: 11756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    ll md = 1000000007;
    const ll mod = (ll)1e9 + 7;
    ll n,m;
    cin>>n>>m;
    if(m==1){
        cout << m << endl;
        return 0;
    }
    ll soinsuu[1000][2];
    rep(i,1000){
        rep(j,2){
            soinsuu[i][j]=0;
        }
    }
    ll count = 2;
    ll flag = 0;
    ll now = 0;
    while(count<500001&&m>1){
        if(m%count==0){
            soinsuu[now][0] = count;
            soinsuu[now][1]++;
            flag++;
            m /= count;
        }else{
            if(flag!=0){
                now++;
                flag=0;
                count++;
            }else{
                count++;
            }
        }
    }
    //cout << soinsuu[0][1] << endl;
    if(soinsuu[0][0]==0||n==1){
        cout << n << endl;
        return 0;
    }
    if(m!=1){
        soinsuu[now][0] = m;
        soinsuu[now][1]++;
    }
    count = 0;
    ll ans = 1;
    while(soinsuu[count][0]!=0){
        ll N = n-1 + soinsuu[count][1];
        ll K = soinsuu[count][1];
        ans *= COM(N,K);
        ans %= MOD;
        /*
        ll kk[K];
        rep(i,K){
            ll ii = i;
            kk[i]=N-ii;
        }
        rep(i,K){
            rep(j,K){
                ll ii = i;
                if(kk[j]%(ii+1)==0){
                    kk[j]/=(ii+1);
                    cout << ii+1 << endl;
                    break;
                }
            }
        }
        rep(i,K){
            ans *= kk[i];
            ans %= mod;
        }
        */
        count++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 12160
#include<stdio.h>

#define N 36

typedef struct{
  char iro;
  int num;
  int turn;
}data;

int main(){
  
  int i,j,n,flag=1,minj;
  data arr1[N],arr2[N],tmp;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    while(1){
      scanf("%c",&arr1[i].iro);
      if(arr1[i].iro!='S'&&arr1[i].iro!='H'&&arr1[i].iro!='C'&&arr1[i].iro!='D'){
	continue;
      }
      scanf("%d",&arr1[i].num);
      break;
    }
      arr1[i].turn=i+1;
      arr2[i]=arr1[i];
  }
  
  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(arr1[j].num<arr1[j-1].num){
	tmp = arr1[j];
	arr1[j] = arr1[j-1];
	arr1[j-1] = tmp;
      }}}
  
  for(j=0;j<n-1;j++){
    printf("%c%d ",arr1[j].iro,arr1[j].num);
  }

  printf("%c%d\n",arr1[n-1].iro,arr1[n-1].num);

  for(i=1;i<n;i++){
    if(arr1[i].num==arr1[i-1].num&&arr1[i].turn-arr1[i-1].turn<0){
      flag=0;
    }}
  if(flag==1)printf("Stable\n");
  else printf("Not stable\n");
  
  flag = 1;
  
  for(i=0;i<n-1;i++){
    minj = i;
    for(j=i;j<=n-1;j++){
      if(arr2[j].num<arr2[minj].num){
	minj = j;
      }
    }
    tmp = arr2[i];
    arr2[i] = arr2[minj];
    arr2[minj] = tmp;
  }
  
  for(i=0;i<n-1;i++){
    printf("%c%d ",arr2[i].iro,arr2[i].num);
  }
  
  printf("%c%d\n",arr2[n-1].iro,arr2[n-1].num);
  
  for(i=1;i<n;i++){
    if(arr2[i].num==arr2[i-1].num&&arr2[i].turn-arr2[i-1].turn<0){
      flag=0;
    }}
  if(flag==1)printf("Stable\n");
  else printf("Not stable\n");
  

  
  return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,k=0,a[100],b[100];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++)
	{
		if(a[i]!=b[i])
			k++;
	}
	if(k>2)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    double r;
    int n;
    while (cin >> r >> n && r){
        map<int, double> hl, hr;
        while (n--){
            int xl, xr, h;
            cin >> xl >> xr >> h;
            hr[xl] = fmax(hr[xl], h);
            hl[xr] = fmax(hl[xr], h);
            FOR(i,xl+1,xr-1){
                hl[i] = fmax(hl[i], h);
                hr[i] = fmax(hr[i], h);
            }
        }

        double ans = fmin(hr[-r], hl[r]) + r;
        FOR(i,-r+1,r-1){
            double h = fmin(hl[i], hr[i]);
            double y = r - sqrt(r*r-i*i);
            ans = fmin(ans, y+h);
        }

        printf("%.10f\n", ans);
    }
    return 0;
}

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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) (container).begin(), (container).end()
#define sortall(container) (sort((container).begin(), (container).end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
T getSum(std::vector<T>& v) {
	T ret = 0;
	for (T& x : v) ret += x;
	return ret;
}

template <typename T>
istream& operator >> (istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;  return is;
}

template <typename S, typename T>
istream& operator >> (istream & is, pair<S, T> & p) {
	is >> p.first >> p.second; return is;
}

istream& operator >> (istream & is, point & p) {
	is >> p.x >> p.y;          return is;
}

template <typename T>
ostream& operator << (ostream & os, const vector<T> & vec) {
	for (const T& x : vec) os << x << " "; return os;
}

template <typename T>
ostream& operator << (ostream & os, const vector<vector<T>> & mat) {
	for (const vector<T>& m : mat)
		os << m << endl; return os;
}
template <typename S, typename T>
ostream& operator << (ostream & os, const pair<S, T> & p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream & os, const set<T> & s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream & os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream & os, const point & p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int A, P;
	cin >> A >> P;
	say((A * 3 + P) / 2);

	return 0;
}


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

int main(void) {
    string str;
    
    getline(cin, str);
    
    while(str.find("apple") != -1)   str.replace(str.find("apple"), 5, "00000");
    while(str.find("peach") != -1)   str.replace(str.find("peach"), 5, "11111");
    while(str.find("00000") != -1)   str.replace(str.find("00000"), 5, "peach");
    while(str.find("11111") != -1)   str.replace(str.find("11111"), 5, "apple");
    
    cout << str << endl;
}


Measured memory_bytes: 3180
K,X=map(int,input().split())
for i in range(K):
    if -1000000<X-K+1+i<=1000000:
        print(X-K+1+i,end=" ")
for j in range(K-1):
    if -1000000<X+1+j<=1000000:
        print(X+1+j,end=" ")

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[365];
set<int>st[26];
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[i]]=i;
		res+=A[i][con[i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[x]];
	auto pre_old=--st[con[x]].lower_bound(x);
	auto next_old=st[con[x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
double rand_double(){
	return (double)rand()/RAND_MAX;
}
signed main(){
	cin>>D;
	rep(i,26){
		cin>>C[i];
		st[i].insert(-1);st[i].insert(D);
	}
	vector<int>last(26,-1);
	rep(i,D){
		int mx=-mod,idx;
		rep(j,26){
			cin>>A[i][j];
			if(chmax(mx,A[i][j]+C[j]*(i-last[j])))idx=j;
		}
		con[i]=idx;st[idx].insert(i);
       last[idx]=i;
	}
	int score_=score();
	cerr<<score_<<endl;
	double C=1970*10000;
	while(1000.*clock()/CLOCKS_PER_SEC<=1970){
		int x=rand()%D,y;
		do{
			y=rand()%26;
		}while(con[x]==y);
		int diff=change(x,y);
		double ti=1970-1000.*clock()/CLOCKS_PER_SEC;

		if(diff>=0||ti/C>rand_double()){
			score_+=diff;
			st[con[x]].erase(x);
			con[x]=y;
			st[y].insert(x);
		}
	}
	rep(i,D)cout<<con[i]+1<<"\n";
	cerr<<score_<<endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

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

    int n, q;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    ll sum = 0;
    for (int &x : a) {
        cin >> x;
        cnt[x]++;
        sum += 1ll * x;
    }
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        sum = sum - (ll) cnt[b] * b + (ll) cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << '\n';
    }
}

Measured memory_bytes: 8168
function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n = Number(stdin.shift());
    const A = stdin.shift().split(' ').map(Number);
    const q = Number(stdin.shift());
    const m = stdin.shift().split(' ').map(Number);

    let totalResults = [];
    let max = '';
    for (let i = 1; i <= n; i++) {
        max += '1';
    }
    let combi = parseInt(max, 2);
    for (let i = 1, l = parseInt(combi, 10); i <= l; i++) {
        let op = i.toString(2);
        op = padding(op, n);
        const targets = A.filter((e, i) => op[i] === '1');
        totalResults.push(targets.reduce((t, c) => t += c));
    }

    for (let i = 0; i < q; i++) {
        console.log(totalResults.includes(m[i]) ? 'yes' : 'no');
    }
}

function padding(str, n) {
    if(str.length > n) return str;
    let diff = n - str.length;
    let pad = '';
    for(let i = 0;i<diff;i++){
        pad += '0';
    }
    return pad + str;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 51732
#include <iostream>

#define MAX 500000


using namespace std;


int parent(long A[], int i)
{
    return i / 2;
}


int left(long A[], int i)
{
    return i * 2;
}


int right(long A[], int i)
{
    return i * 2 + 1;
}

int H;
void max_heapify(long A[], int i)
{
    int l, r;
    l = left(A, i);
    r = right(A, i);

    int max_i;
    max_i = l <= H && A[l] > A[i] ? l : i;
    max_i = r <= H && A[r] > A[max_i] ? r : max_i;

    if (max_i != i) {
        int tmp = A[max_i];
        A[max_i] = A[i];
        A[i] = tmp;

        max_heapify(A, max_i);
    }
}


void build_max_heap(long A[], int H)
{
    for (int i = H / 2; i >= 1; i--)
        max_heapify(A, i);
}


long A[MAX + 1];
int main()
{
    cin >> H;
    for (int i = 1; i <= H; i++)
        cin >> A[i];

    build_max_heap(A, H);

    for (int i = 1; i <= H; i++)
        cout << " " << A[i];
    cout << endl;
}


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

int main() {
    int n;
    ll k;
    cin>>n>>k;
    vector<pair<ll,ll>> v(n);
    rep(i,n) cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end());
    ll res=0,sum=0;
    rep(i,n) {
        sum+=v[i].second;
        if (sum>=k) {
            res=v[i].first;
            break;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int h,w,q;

void init(vvi& a) {
  drep(i,h)drep(j,w) {
    a[i+1][j+1] = a[i][j];
  }
  rep(i,h+1) a[i][0] = 0;
  rep(j,w+1) a[0][j] = 0;
  rep(i,h)rep(j,w+1) a[i+1][j] += a[i][j];
  rep(i,h+1)rep(j,w) a[i][j+1] += a[i][j];
}
int sum(vvi& a, int si, int sj, int ti, int tj) {
  return a[ti][tj]+a[si][sj]-a[si][tj]-a[ti][sj];
}

int main() {
  scanf("%d%d%d",&h,&w,&q);
  vvi a(h+1,vi(w+1));
  rep(i,h) {
    string ns;
    cin>>ns;
    rep(j,w) a[i][j] = ns[j]=='1';
  }
  vvi b(h+1,vi(w+1));
  vvi c(h+1,vi(w+1));
  rep(i,h)rep(j,w-1) b[i][j] = a[i][j]&&a[i][j+1];
  rep(i,h-1)rep(j,w) c[i][j] = a[i][j]&&a[i+1][j];
  init(a);
  init(b);
  init(c);

  rep(qi,q) {
    int si,sj,ti,tj;
    scanf("%d%d%d%d",&si,&sj,&ti,&tj);
    --si; --sj;
    int ans = 0;
    ans += sum(a,si,sj,ti,tj);
    ans -= sum(b,si,sj,ti,tj-1);
    ans -= sum(c,si,sj,ti-1,tj);
    printf("%d\n",ans);
  }
  return 0;
}






















Measured memory_bytes: 48896
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

long long int a, b, c;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0){
		cout<<0;
		return 0;
	}
	if(max(max(a, b), c)==a)cout<<b*c;
	else if(max(max(a, b), c)==b)cout<<a*c;
	else if(max(max(a, b), c)==c)cout<<a*b;
	return 0;
}

Measured memory_bytes: 256
# abc177_a.py
# https://atcoder.jp/contests/abc177_a


# [開発時用] ログ関数
def lg(value):
    flag = False
    flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 1
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    # S = lines[0]
    # X = int(lines[0])
    D, T, S = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    results = list()

    if D / S > T:
        result = 'No'
    else:
        result = 'Yes'

    results.append(result)

    return results


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()


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

int main(){
	int n, x;
	cin >> n;    
	vector<int> a[n+1];
	
	for (int i=2; i<=n; i++){  
		cin >> x;           
		a[x].push_back(i);
	}
	
	for (int i=1; i<=n; i++){
		cout << a[i].size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 14532
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    if(2*x>=a*a*b){
        double deg=(2.0*a*a*b-2.0*x)/(1.0*a*a*a);
        printf("%.10f",180.0/acos(-1)*atan(deg));
    }
    else{
        double deg=1.0/(2.0*x/(1.0*a*b*b));
        printf("%.10f",180.0/acos(-1)*atan(deg));
    }
    return 0;
}


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

int main() {
  vector<int> v;

  int tmp = 0;
  do {
    cin >> tmp;
    v.push_back(tmp);
  } while(tmp != 0);

  for (int i = 0; i < v.size()-1; i++) {
    cout << "Case " << i+1 << ": " << v[i] << endl;
  }
    
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int MaxN = 1e5+5;
int dp[MaxN][13];
string s;
int solve(int i,int sum){
    if(i==s.length()){
        return sum==5;
    }
    int &ans = dp[i][sum];
    if(ans!=-1){
        return ans;
    }
    int res = 0;
    if(s[i]=='?'){
        for(int pos=0;pos<10;pos++){
            int x = pos;
            res = res + solve(i+1,(sum*10+x)%13);
            res=res%MOD;
        }
    }else{
        int x = s[i]-'0';
        res = solve(i+1,(sum*10+x)%13);
        res=res%MOD;
    }

    return ans=res%MOD;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
    
    return 0;
    
}



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

int main() {
  string script;
  cin >> script;
  
  char step;
  string result = "Yes";
  for (int i=1; i<=script.size(); i++) {
    step = script.at(i-1);
    if (i%2 == 0 && step == 'R') {
      result = "No";
    }
    if (i%2 == 1 && step == 'L') {
      result = "No";
    }
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define all(x) (x).begin(),(x).end()


int main(){
  int N,T;
  cin>>N>>T;
  vector<int> st(N),ar(N);
  vector<string> name(N+2);
  rep(i,N){
    int h,m;
    scanf("%d:%d",&h,&m );
    st[i] = h*60+m;
    string dam;
    cin>>dam;
    
    scanf("%d:%d",&h,&m );
    ar[i] = h*60+m;
    cin>>name[i];
    
  }
  vector<string>res_name;
  vector<int>res_time;
  rep(i,N-1){
    if(st[i+1]-ar[i]>=T){
      res_time.push_back(st[i+1]-ar[i]);
      res_name.push_back(name[i]);
    }
  }
  cout<<res_time.size()<<endl;
  rep(i,res_time.size()){
    cout<<res_name[i]<<" "<<res_time[i]<<endl;
  }
}

Measured memory_bytes: 3280
#include<stdio.h>

int main(void){

	int n,i,max;
	scanf("%d",&n);
	int data[1000000];
  int count[1000000]={};
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<n;i++){
		++count[data[i]-1];
		++count[data[i]+1];
		++count[data[i]];
	}
	for(i=0;i<1000000;i++){
	if(max < count[i]){
		max = count[i];
	}
	}

printf("%d\n",max);

return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    ll k;
    cin>>k;
    if(k==0){
        cout<<2<<endl;
        cout<<0<<" "<<0<<endl;
    }
    else{
        if(k==1){
            cout<<2<<endl;
            cout<<0<<" "<<2<<endl;
        }
        else{
            if(k<=50){
                cout<<k<<endl;
                for(int i=1;i<=k;i++){
                    if(i==k)cout<<i<<endl;
                    else cout<<i<<" ";
                }
            }
            else{
                ll t = k/50-1;
                ll rest = k%50;
                vector<ll>ans(50);
                for(int i=0;i<50;i++)ans[i]=i+1+t;
                for(int i=0;i<rest;i++)ans[49-i]++;
                cout<<50<<endl;
                for(int i=0;i<50;i++){
                    if(i==49)cout<<ans[i]<<endl;
                    else cout<<ans[i]<<" ";
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = INF;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        ans = min(ans, a + b);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
/*


              STAY HOME
                  STAY SAFE
                        DO CODE :)


*/

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

using namespace __gnu_pbds;
using namespace std;

#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld%lld",&x,&y)
#define in3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define out(x) printf("%lld",x)
#define outspace(x) printf("%lld ",x)
#define outln(x) printf("%lld\n",x)
#define ll int
#define ld long double
#define pb push_back
#define p push
#define mkp make_pair
#define ff first
#define PLL pair<ll,ll>
#define ss second
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> >
#define all(x) x.begin(),x.end()
#define F(i,a,b) for(ll i=a;i<b;i++)
#define RF(i,a,b) for(ll i=a;i>b;i--)
#define mset(a,b) memset((a),(b),sizeof((a)))
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define RMOD 998244353
#define INF 10000000000000000
#define MINF LONG_LONG_MIN
#define MAXF LONG_LONG_MAX
#define zad tree< PLL, null_type, less< PLL >, rb_tree_tag, tree_order_statistics_node_update >
const ll N = 301;
#define OuterLoop ll t;scanf("%lld",&t);while(t--)

double dp[N][N][N]={};
ll n;

double find(ll a,ll b,ll c)
{
    if(dp[a][b][c]>0) return dp[a][b][c];

    if(a==0 && b==0 && c==0) return 0;
    double ans = 0;
    double cnt = a + b + c;

    if(a > 0) ans += (double)a * find(a-1, b, c);
    if(b > 0) ans += (double)b * find(a+1, b-1, c);
    if(c > 0) ans += (double)c * find(a, b+1, c-1);

    dp[a][b][c] = (ans + n)/cnt;
    return dp[a][b][c];
 }


void solve()
{

    cin>>n;

    map<ll,ll> mp;
    mp[1]=0;
    mp[2]=0;
    mp[3]=0;

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

    double xx= find(mp[1],mp[2],mp[3]);

    precision(xx,10);
}


signed main()
{
    solve();
}


Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll mpow(ll x,ll n){
    ll res = 1;
    while(n != 0){
        if(n&1) res = res*x % mod;
        x = x*x % mod;
        n = n >> 1; 
    }
    return res;
}
ll fac(ll i){
    static ll fatorial[200000+1]={0};

    if(fatorial[i]) return fatorial[i];
    else if(i==0) return fatorial[0] = 1;
    else return fatorial[i] = fac(i-1)*i % mod;
}
ll ifac(ll i){
    static ll ifactorial[200000+1]={0};

    if(ifactorial[i]) return ifactorial[i];
    else if(i==0) return ifactorial[0] = 1;
    else return ifactorial[i] = ifac(i-1)*mpow(i,mod-2) % mod;
}
ll comb(ll a,ll b){
    if(a==0 && b==0) return 1;
    if(a<b || a<0) return 0;
    ll tmp = ifac(a-b)*ifac(b) % mod;
    return tmp*fac(a) % mod;
}


int main(){
    ll h,w,a,b,ans=0;
    cin >> h >> w >> a >> b;
    for(int i = 0;i < h-a;i ++){
        ans += comb(i+b-1,i)*comb(w+h-2-b-i,w-1-b);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	 cin>>x>>y;
	 if((y>4*x)||(y<2*x)||(y%2!=0)){
	 	cout<<"No";
	 }else{ 
	 	cout<<"Yes";
	 	
	 }
}

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

int H, W;
bool S[20][20];
int dist[20][20];

void reset() {
    for (int i = 0; i < 20; ++i) {
        for (int j = 0; j < 20; ++j) {
            dist[i][j] = -1;
        }
    }
}

int calc_max_path(int i, int j) {
    std::vector<std::pair<int, int>> direction = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};  
    dist[i][j] = 0;
    std::queue<std::pair<int, int>> queue;
    queue.push({i, j});
    int max = 0;
    while (queue.empty() == false) {
        const auto& p = queue.front(); queue.pop();
        int cur_x = p.first, cur_y = p.second;
        for (const auto& d : direction) {
            int dx = cur_x + d.first, dy = cur_y + d.second;
            if (dx < 0 || dx > (H-1) || dy < 0 || dy > (W-1)) {
                continue;
            }

            if (S[dx][dy] == false) {
                continue;
            }

            if (dist[dx][dy] != -1) {
                continue;
            }

            dist[dx][dy] = dist[cur_x][cur_y] + 1;
            max = std::max(max, dist[dx][dy]);
            queue.push({dx, dy});
        }
    }

    return max;
}

int main() {
    std::cin >> H >> W;

    char c;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            std::cin >> c;
            if (c == '.') {
                S[i][j] = true;
            } else {
                S[i][j] = false;
            }
        }
    }

    int max = 0; 
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == false) {
                continue;
            }

            reset();
            const int r = calc_max_path(i, j);
            max = std::max(max, r);
        }
    }

    std::cout << max << std::endl;

    return 0;
}


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

using namespace std;

int main(){

	int minx,miny,maxx,maxy;
	int w,h;
	int t;
	cin>>t;
	while(cin>>minx>>miny>>w>>h){
		maxx=minx+w;
		maxy=miny+h;
		int n;
		cin>>n;
		int cnt=0;
		for(int i = 0; i < n; i++){
			int px,py;
			cin>>px>>py;
			if(px>=minx&&py>=miny&&px<=maxx&&py<=maxy){
				cnt++;
			}
		}
		cout<<cnt<<endl;
		t--;
		if(t==0)
			break;
	}

	return 0;
}

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

char mp[8][8];

void ans(char mp[8][8]){
    for(int i = 0 ; i < 8 ; i++){
        for(int j = 0 ; j < 8 ; j++){
            if(mp[i][j]=='1'){
                if(mp[i][j+1]=='1'&&mp[i+1][j]=='1'&&mp[i+1][j+1]=='1'){
                    cout << 'A' << endl;
                    return;
                }
                else if(mp[i+3][j]=='1'){
                    cout << 'B' << endl;
                    return;
                }
                else if(mp[i][j+3]=='1'){
                    cout << 'C' << endl;
                    return;
                }
                else if(mp[i+2][j-1]=='1'){
                    cout << 'D' << endl;
                    return;
                }
                else if(mp[i+1][j+2]=='1'){
                    cout << 'E' << endl;
                    return;
                }
                else if(mp[i+2][j+1]=='1'){
                    cout << 'F' << endl;
                    return;
                }
                else{
                    cout << 'G' << endl;
                    return;
                }
            }
        }
    }
}

int main(){
    while(cin >> mp[0][0]){
        for(int i = 0 ; i < 8 ; i++){
            for(int j = 0 ; j < 8 ; j++){
                if(!i&&!j) continue;
                else cin >> mp[i][j];
            }
        }
        ans(mp);
    }
    
    return 0;
}

Measured memory_bytes: 1132
#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>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  rep(i,k){
    if(i%2==0){
      if(n%2){
        n--;
      }
        n/=2;
        m+=n;
    } else {
      if(m%2){
        m--;
      }
        m/=2;
        n+=m;
    }
  }
  cout << n << " " << m << endl;
  return 0;
}

Measured memory_bytes: 256