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

int main() {
  int H,W;
  cin>>H>>W;
  vector<string> pic(H);
  for(int i=0;i<H;i++){
    cin>>pic.at(i);
  }
  for(int i=0;i<W+2;i++){
    cout<<'#';
  }
  cout<<""<<endl;
  for(int i=0;i<H;i++){
    cout<<'#'<<pic.at(i)<<'#'<<endl;
  }
  for(int i=0;i<W+2;i++){
    cout<<'#';
  }
  cout<<""<<endl;
}


Measured memory_bytes: 3600
n = int(input())
al = list(map(int,input().split()))

res = 0
bits = [0]*60
for a in al:
    i = 0
    b = a
    while b:
        bits[i] += b&1
        b = b >> 1
        i += 1

res = 0

for j in range(60):
    res += bits[j] * (n - bits[j])  * (2 ** j)

print(res % (10 ** 9 + 7))

Measured memory_bytes: 122936
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine()) - k;
		}
		br.close();

		long[] b = new long[n + 1];
		for (int i = 0; i < n; i++) {
			b[i + 1] = b[i] + a[i];
		}

		int[] c = zaatu(b);
		long t = tentousuu(c);
		long ans = (long) n * (n + 1) / 2 - t;
		System.out.println(ans);
	}

	static int[] zaatu(long[] a) {
		TreeMap<Long, Integer> map = new TreeMap<>();
		for (int i = 0; i < a.length; i++) {
			map.put(a[i], null);
		}
		Long[] arr = map.keySet().toArray(new Long[0]);
		int cnt = 0;
		for (Long i : arr) {
			cnt++;
			map.put(i, cnt);
		}
		int[] b = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			b[i] = map.get(a[i]);
		}
		return b;
	}

	static long tentousuu(int[] a) {
		int n = a.length;
		BIT bit = new BIT(n + 1);
		long ret = 0;
		for (int i = 0; i < n; i++) {
			ret += i - bit.sum(a[i]);
			bit.add(a[i], 1);
		}
		return ret;
	}

	static class BIT {
		int n;
		long[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new long[n + 1];
		}

		void add(int idx, long val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		long sum(int idx) {
			long sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}
}


Measured memory_bytes: 61148
#include <stdio.h>
 
int main()
{
    int n;
    long int akhir=0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
        akhir+=i;
        }
    }
    printf("%ld\n", akhir);
    return 0;
}

Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

class unionfind {
	vector<int> par;
	vector<int> sz;
public:
	unionfind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
		sz = vector<int>(n, 1);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int si(int x) {
		return sz[find(x)];
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, k, l;
	cin >> n >> k >> l;
	unionfind uni(n), uni2(n);
	rep(i, k) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		uni.unite(p, q);
	}
	rep(i, l) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		uni2.unite(r, s);
	}
	map<P, int> mp;
	rep(i, n) {
		int p = uni.find(i);
		int q = uni2.find(i);
		mp[P(p, q)]++;
	}
	rep(i, n) {
		int p = uni.find(i);
		int q = uni2.find(i);
		cout << mp[P(p, q)] << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 18048
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

type rest struct {
	S   string
	P   int
	idx int
}
type rests []rest
type rests2 []rest
type mystrings []string

func (a rests) Len() int           { return len(a) }
func (a rests) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rests) Less(i, j int) bool { return a[i].P > a[j].P }

func (a rests2) Len() int           { return len(a) }
func (a rests2) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rests2) Less(i, j int) bool { return a[i].S < a[j].S }

func (a mystrings) Len() int           { return len(a) }
func (a mystrings) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a mystrings) Less(i, j int) bool { return a[i] < a[j] }

func main() {
	N := getStdinInt()
	r := make(rests, N)
	ls := make([]string, N)
	for i := 0; i < N; i++ {
		list := getStdinArr()
		r[i].S = list[0]
		r[i].P, _ = strconv.Atoi(list[1])
		r[i].idx = i + 1
		find := false
		for _, val := range ls {
			if r[i].S == val {
				find = true
				break
			}
		}
		if !find {
			ls[i] = r[i].S
		}
	}

	sort.Sort(rests(r))
	sort.Sort(mystrings(ls))
	for _, val2 := range ls {
		for _, val := range r {
			if val2 == val.S {
				fmt.Printf("%d\n", val.idx)
			}
		}
	}

	/*
			func (a ByAge) Len() int { return len(a) }
		func (a ByAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
		func (a ByAge) Less(i, j int) bool { return a[i].Age < a[j].Age }

		--以下実行例
		people := []Person{
		{"A", 1},
		{"D", 4},
		{"B", 2},
		{"C", 3},
		}
		sort.Sort(ByAge(people))
	*/
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main(){
    std::vector<int> A;
    int q;
    int order,num;

    std::cin>>q;

    int i=0;
    for(i=0;i<q;i++){
        std::cin>>order;
        if(order==2){
            A.pop_back();
        }else if(order==0){
            std::cin>>num;
            A.push_back(num);
        }else if(order==1){
            std::cin>>num;
            std::cout<<A[num]<<std::endl;
        }
    }
    return 0;
}



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

using namespace std;

int main() {
  int N;
  cin>>N;
  vector<vector<int>> dp(3, vector<int>(N+1, 0));
  int a,b,c;
  for(int i=0;i<N;i++) {
    cin>>a>>b>>c;
    dp[0][i+1] = max(dp[1][i], dp[2][i]) + a;
    dp[1][i+1] = max(dp[0][i], dp[2][i]) + b;
    dp[2][i+1] = max(dp[0][i], dp[1][i]) + c;
  }
  
  cout<< max(dp[0][N], max(dp[1][N], dp[2][N]));
  return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    if (s.size() + 1 != t.size()) {
        cout << "No" << endl;
        return 0;
    }
    if (s != t.substr(0, s.size())) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  string s;
  cin >> s;
  REP(i,3) {
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


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

bool solve() {
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for (int i = 0; i < h; i++) cin >> g[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int cnt = 0;
            if (i + 1 < h && g[i + 1][j] == '#') cnt++;
            if (j + 1 < w && g[i][j + 1] == '#') cnt++;
            if (cnt == 2) return false;
        }
    }
    return true;
}

int main() {
    puts(solve() ? "Possible" : "Impossible");
}


Measured memory_bytes: 256
def yakusu(x):
    ans=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            ans.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      ans.append(x)
    return ans
def main():
    a,b = map(int,input().split())	
    ans=0
    y1=yakusu(a)
    for i in y1:
        if b%i==0:
            ans+=1
    print(ans)

main()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        string str;
        cin >> str;
        if(str[0] == str[2] ){
            cout <<  "Yes"  <<  endl;
        }else{
            cout <<  "No"  <<  endl;
        }

        return 0;
    }

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

using namespace std;

int main() {
    int n, minv, maxv = -2000000000;
    cin >> n;
    int data[n];
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }

    minv = data[0];
    for (int j = 1; j < n; j++) {
        maxv = max(maxv, data[j] - minv);
        minv = min(minv, data[j]);
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 3856
#include <stdio.h>

int main(void){
	
	int i;
	char s[13];
	
	for(i=0;i<13;i++){
		if(i==4){
			s[i] = ' ';
		}else{
			scanf("%c",&s[i]);
		}
	}
	
	for(i=0;i<13;i++){
		printf("%c",s[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
n = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)
m = gets.chomp.to_i
p, x = [], []
m.times do |i|
  p[i], x[i] = gets.chomp.split.map(&:to_i)
end

sum_t = t.inject(:+)

m.times do |i|
    puts sum_t - t[p[i]-1] + x[i]
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;
  if(n == 7 || n == 5 || n == 3){
    cout << "YES\n";
  }else{
    cout << "NO\n";
  }
  return 0;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
a = []
a = gets.split.map(&:to_i)
a.insert(0,0)
a.push(0)
s = 0
for i in 1..n+1
s += (a[i-1]-a[i]).abs
end
#puts s
for i in 1..n
  puts s + (a[i-1]-a[i+1]).abs - (a[i-1]-a[i]).abs - (a[i]-a[i+1]).abs
end

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = 0; i < n-k; ++i) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> list(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &list[i]);
    }
    if (n == 1) {
        printf("%d", 1);
        return 0;
    }
    if (n == 2) {
        if (abs(list[0] - list[1]) <= 1) {
            printf("%d", 2);
        } else {
            printf("%d", 1);
        }
        return 0;
    }
    vector<int> num_list(n, 0);
    for (int j = 0; j < n; j++) {
        num_list[list[j]] = num_list[list[j]] + 1;
    }
    int max = 1;
    for (int k = 0; k <= n - 3; k++) {
        if (max < num_list[k] + num_list[k + 1] + num_list[k + 2]) {
            max = num_list[k] + num_list[k + 1] + num_list[k + 2];
        }
    }
    printf("%d", max);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;
const ld EPS = 1e-4;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

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

vvi graph(int n, int m){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	string s; cin>>s;
	cout<<s<<(s.back()=='s'?"es":"s")<<ENDL;

}
int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#define P pair<int,int>
using namespace std;

int main() {
	int bus[] = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0 };
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d;
		scanf("%d%d", &c, &d);
		vector<int>l(100);
		for (int e = 0; e < 14; e++) {
			if (bus[e] == c) {
				vector<int>f;
				for (int g = e; g < 30; g++) {
					f.push_back(bus[g]);
					if (bus[g] == d)break;
				}
				if (f.size() < l.size())l = f;
			}
		}
		for (int x = 0; x < l.size(); x++) {
			if (x)printf(" ");
			printf("%d", l[x]);
		}
		puts("");
	}
}

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

int main() {
	int n;
	scanf("%d", &n);
	int curx = 0, cury = 0, curt = 0;
	for(int i = 0; i < n; i++) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		int d = abs(x-curx) + abs(y-cury);
		if(d > (t-curt) || (t-curt-d)%2 == 1) {
			printf("No\n");
			return 0;
		}
		curx = x;
		cury = y;
		curt = t;
	}
	printf("Yes\n");
}

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

typedef long long ll;

ll solve(int i, ll A, ll B)
{
	if(i == 0) return A == B ? 1 : 2; 
	if(((A >> i) & 1) != ((B >> i) & 1))
		return (1ll << i) - A + std::min((1ll << i) - A + solve(i - 1, 0, B - (1ll << i)), 1ll << i);
	else return solve(i - 1, A & ((1ll << i) - 1), B & ((1ll << i) - 1));
}

int main()
{
	ll A, B; scanf("%lld%lld", &A, &B);
	printf("%lld\n", solve(60, A, B));
}

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

int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main(){
	string S;
	cin>>S;
	REP(i,S.length()) cout<<"x";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int func(int a)
{
  int z = 0;
  while(a > 0){
    int buf = a/10;
    buf *= 10;
    z += a-buf;
    a/=10;
  }
  return z;
}
int main()
{
  int n;
  cin >> n;
  if(n%func(n)==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, L;
    std::cin >> N >> L;

    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }

    std::sort(S.begin(), S.end());
    std::string sum;
    for (int i = 0; i < N; i++) {
        sum += S[i];
    }

    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0) {
				break;
			}
			StringBuilder sb = new StringBuilder();
			StringBuilder sb2 = new StringBuilder();
			for(int i = 0; i < W; i++) {
				if(i % 2 == 0) {
					sb.append("#");
					sb2.append(".");
				}else {
					sb.append(".");
					sb2.append("#");
				}
			}
			for(int i = 0; i < H; i++) {
				if(i % 2 == 0) {
					System.out.println(sb.toString());
				}else {
					System.out.println(sb2.toString());
				}
			}
			System.out.println();
		}
		scan.close();
	}
}


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

const int MAXN = 100010;
int N;
pair<int, int> p[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int x; scanf("%d", &x);
		p[i] = {x, i};
	}
	sort(p, p + N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if ((i - p[i].second) % 2) {
			cnt++;
		}
	}
	printf("%d\n", cnt/2);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int a[100000];
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    int ans = 0;
    for (int i = 0, j = 1; i < n; i = j, j = i + 1) {
        int op = 0;
        while (j < n && (op * (a[j - 1] - a[j]) <= 0)) {
            if (a[j - 1] < a[j]) op = 1;
            if (a[j - 1] > a[j]) op = -1;
            ++j;
        }
        ++ans;
    }
    printf("%d\n", ans);
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    int max, cnt;
    max = 0;
    cnt = 0;
    for(int i = 0; i < n; i++){
        if(h.at(i) >= max){
            max = h.at(i);
            cnt += 1;
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		Scanner sc 	= new Scanner(System.in);
		int seconds	= Integer.parseInt(sc.next());
		
		int answerHours   = seconds / (60 * 60);
		int answerMinites = (seconds - answerHours * (60 * 60)) / 60;
		int answerSeconds = seconds - (answerHours * (60 * 60)) - answerMinites * 60;
		
		System.out.println(answerHours + ":" + answerMinites +":" + answerSeconds);
		
		sc.close();
	}
}



Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll i=(a);i>=b;j--)

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

const ll N = 100010, M = 1e9 + 7;
ll n, a[N], v[N];

void solve(){
	cin >> n;
	fi(1, n) cin >> a[i];
	fi(1, n) v[i] = 0;
	ll m = 0;

	ll pos = 1;
	while(true) {
		if(v[pos] == 1) {
			cout << -1 << "\n";
			return;
		}

		if(pos == 2) {
			cout << m << "\n";
			return;
		}

		v[pos] = 1;
		pos = a[pos];
		m++;
	}
}

int main(){
	//freopen("input.txt", "r", stdin);		//Comment
	//freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

#define NUM 256

int main(void){
  char card[NUM] = {0}, cardcpy[NUM] = {0};
  int m, h, i, j, k;
  
  for (;;) {
    scanf("%s", card);
    if (!strcmp(card, "-"))
      break;
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf("%d", &h);
      strncpy(cardcpy, card, h);
      // shift to front
      for (j = h; j < strlen(card); j++)
	card[j - h] = card[j];
      // put into back
      for (k = 0; k < h; k++)
	card[strlen(card) - h + k] = cardcpy[k];
    }
    printf("%s\n", card);
  }
  
  return 0;
}

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

int main() {
  ll a, b;
  cin >> a >> b;
  if (a == b) {
    cout << a << endl;
    return 0;
  }
  double k = (a + b) / 2.0;
  if (ceil(k) == floor(k)) {
    cout << int(k) << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

const string YES_STR = "Yes";
const string NO_STR = "No";

void solve(long long A, long long B) {
	YES(A * B % 2);
}

signed main() {
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

int d, t, s;
void run(){
    cin >> d >> t >> s;
    DEBUG(1.0 * d / s <= t ? "Yes" : "No");

}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 3604
H, W = map(int, input().split())
if H == W == 2:
    print(1)
elif H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    b = H // 3 * W
    c = (H // 3 + 1) * W
    d = W // 3 * H
    e = (W // 3 + 1) * H
    print(min(max(b, (H - H // 3) * ((W + 1) // 2)) - min(b, (H - H // 3) * (W // 2)),
              max(c, (H - H // 3 - 1) * ((W + 1) // 2)) - min(c, (H - H // 3 - 1) * (W // 2)),
              max(d, (W - W // 3) * ((H + 1) // 2)) - min(d, (W - W // 3) * (H // 2)),
              max(e, (W - W // 3 - 1) * ((H + 1) // 2)) - min(e, (W - W // 3 - 1) * (H // 2)), H, W))


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

int main(void){
    // Your code here!
    string S;cin>>S;
    long long count=0;
    long long ans=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='W'){
            ans+=i-count;
            count++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3724
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	M := nextInt()
	pq := make(priorityQueue, N)
	for i := 0; i < N; i++ {
		pq[i] = &item{
			value: nextInt(),
			index: i,
		}
	}

	heap.Init(&pq)

	for i := 0; i < M; i++ {
		it := heap.Pop(&pq).(*item)
		heap.Push(&pq, &item{
			value: it.value / 2,
		})
	}

	var ans int
	for _, it := range pq {
		ans += it.value
	}

	fmt.Println(ans)
}

// PriorityQueue. ----------

type item struct {
	value int // The value is priority.
	index int
}

type priorityQueue []*item

func (pq priorityQueue) Len() int { return len(pq) }

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i].value > pq[j].value
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *priorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *priorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // Avoid memory leak.
	item.index = -1 // For safety.
	*pq = old[0 : n-1]

	return item
}

func (pq *priorityQueue) update(item *item, value int) {
	item.value = value
	heap.Fix(pq, item.index)
}

// ---------- PriorityQueue.

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

#define ll long long
#define FOR(k,a,b) for(ll k=(a); k < (b); k++)
#define FORE(k,a,b) for(ll k=(a); k <= (b); k++)
#define REP(k,a) for(ll k=0; k < (a); k++)

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

   cout<<min(min(a+b,a+c),b+c);
   
   cout << endl;
   return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,mn=INT_MAX,i,x,j,a=0,t,k,b=-1,mx=-1,cnt=0,c=0; 
 st s,str; char strn;
cin>>n>>m; //a=n; n-=1; 
ll ara[n+1],bra[n+1],taj[n+1];
memset(ara,0,sizeof(ara));
//for(i=1;i<=n;i++) cin>>ara[i]; 
  /*for(i=1;i<=9;i++)
   {  
     for(j=1;j<=9;j++)
      {
        if(i*j==n)
           {
            cout<<"Yes";
               rt;
             }
        }
      
      
   } */     
  
   if(n>=10 || m>=10) cout<<-1<<endl;    
  else   cout<<n*m<<endl;
    
 
    rt;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, K;
	cin >> N >> K;
	cout << (N%K==0 ? 0 : 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[0]*(n-k+1)
ans=0
Mod=10**9+7
M=10**6 #書き換え
fac=[0]*M
finv=[0]*M
inv=[0]*M

#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
b[0]=a[n-1]-a[0]
for i in range(1,n-k+1):
    res=a[n-i-1]-a[i]
    b[i]=res+b[i-1]
    b[i]%=Mod
for i in range(n-k+1):
    ans+=(COM(n-2-i,k-2)*b[i])%Mod
    ans%=Mod
print(ans)


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int, int> ii;

const ll mod = 1e9 + 7;
const ll INF = (1LL<<50);
const double EPSILON = 0.001;
const int N = 200005;
ii solve(string s){
	ii ans;
	int op = 0, cl = 0;
	for(char c:s){
		if(c == ')'){
			if(op > 0) op--;
			else cl++;
		}else op++;
	}
	ans.snd = cl;
	op = 0, cl = 0;
	reverse(all(s));
	for(char c:s){
		if(c == '('){
			if(cl > 0) cl--;
			else op++;
		}else cl++;
	}
	ans.fst = op;
	return ans;
}
int main(){
	fastio;
	int n;
	cin >> n;
	vector<ii> v1, v2;
	for(int i = 0; i < n; i++){
		string s;cin >> s;
		ii x = solve(s);
		if(x.fst - x.snd >= 0)
			v1.pb(x);
		else v2.pb(x);
	}
	sort(all(v1), [&](const ii a, const ii b){
		if(a.snd != b.snd)
			return a.snd < b.snd;
		return a.fst > b.fst;
	});
	sort(all(v2), [&](const ii a, const ii b){
		if(a.fst != b.fst)
			return a.fst > b.fst;
		return a.snd < b.snd;
	});
	v1.insert(v1.end(), all(v2)); // concatenate
	int ans = 1, sum = 0;
	for(auto i:v1){
		sum -= i.snd;
		if(sum < 0)ans = 0;
		sum += i.fst;
	}
	cout << (ans and sum == 0 ? "Yes":"No") << '\n';
	return 0;
}


Measured memory_bytes: 18828
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
int ct[26];
int ans[26];

int main() {
	int n;
	si(n);
	string s;
	
	for(int i=0;i<26;i++) ans[i]=1000000;
	
	for(int i=0;i<n;i++){
	    cin>>s;
	    memset(ct,0,sizeof ct);
	    
	    for(int j=0;j<s.size();j++) ct[s[j]-'a']++;
	    
	    for(int j=0;j<26;j++)
	        ans[j]=min(ans[j],ct[j]);
	  
	}
	
	for(int i=0;i<26;i++){
	    while(ans[i]>0){
	        cout<<(char)(i+'a');
	        ans[i]--;
	    }
	}
	cout<<endl;
	return 0;
}

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

int main()
{
    int N,A,B;
    cin >> N >> A >> B;

    int sum = 0;

    for(int i = 1; i <= N; i++)
    {
        int tmp = i;
        int tmpsum = 0;
        while(tmp > 0)
        {
            tmpsum += tmp % 10;
            tmp /= 10;
        }
        if(tmpsum <= B && A <= tmpsum)
        {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
def calc_score(sch):
    d=[0]*26
    score=0
    for i in range(dur):
        j=sch[i]-1
        s=S[i]
        score+=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
        d[j]=i+1
    return score

def greedy(dur,c,S):
    sch=[]
    d=[0]*26
    r=4
    for i in range(dur):
        t=0
        s=S[i]
        m=-1<<64
        for j in range(26):
            alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)])
            if alt>m:
                m=alt
                t=j
        sch.append(t+1)
        d[t]=i+1
    return sch

dur=int(input())
c=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(dur)]

sch=greedy(dur,c,S)

for i in sch:
    print(i)


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

int main()
{
    int T,S;
    cin>>T>>S;
    int a[T]={0};
    for(int i=0; i<T; i++)
    {
        cin>>a[i];
    }
    int start = 0 , hop = 1;
    for(int i=0; i<T; i++)
    {
        start+=a[i];
        //cout<<start<<" "<<S<<endl;
        if(S>=start){
            hop++;
        }
    }
    cout<<hop<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        if (x >= 0 && x <= 1) {
            if (x == 0) {
                System.out.println(1);
            } else if (x == 1) {
                System.out.println(0);
            }
        } else {
            System.out.println("error");
        }
    }

}


Measured memory_bytes: 26916
#include<stdio.h>
int main()
{
    int i,j,k,c=0,n,t,fixed,half,m;
    scanf("%d %d",&m,&n);
    int array1[n],array2[n],array[m];
    for(i=0;i<m;i++)
        array[i]=0;
    for(i=0;i<n;i++){
        scanf("%d %d",&array1[i],&array2[i]);
        if(array1[i]==1){
            array[array2[i]-1]=array2[i];
        }
    }
    fixed=m;
    for(i=0;i<n;i++){
        if(array2[i]==fixed){
            if(array[array1[i]-1]==array1[i]){
                c=1;
                break;
            }
        }
    }
    if(c==1)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 3944
fun main(args: Array<String>) {
    readLine()?.toLong()?.let {
        var count = 0L
        for (i in 1..it) {
            if (i.rem(5) == 0L || i.rem(3) == 0L){
            } else {
                count += i
            }
        }
        println(count)
    }
}

Measured memory_bytes: 34492
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;



long long int n,k,a[2000],sum=0,up=0,down=0,res=0;
int main() {
    long long int count=0;
    string str,str2;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n>>k;
	for(int i=k-n+1;i<=k+n-1;i++){
		cout<<i<<" ";
	}
} 


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

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

    ll N = s.size();

    vector<ll> R(N, 0);
    vector<ll> L(N, 0);
    vector<ll> ans(N, 0);

    for (int i = 0; i < N;i++){
        if(s[i] == 'R' && (i==0 ||R[i-1] < 2)){
            int tmp = i+1;
            while(s[tmp] =='R'){
                tmp++;
            }
            R[i] = tmp - i;
        }else if(i != 0 && R[i-1] >= 2){
            R[i] = R[i - 1] - 1;
        }else{
            R[i] = 0;
        }
    }

    for (int i = N-1; i > 0; i--)
    {
        if (s[i] == 'L' && (i == N - 1 ||L[i + 1] < 2))
        {
            int tmp = i - 1;
            while (s[tmp] == 'L')
            {
                tmp--;
            }
            L[i] = i - tmp;
        }
        else if (L[i + 1] >= 2 && i != N - 1)
        {
            L[i] = L[i + 1] - 1;
        }
        else
        {
            L[i] = 0;
        }
    }

    for (int i = 0; i < N;i++){
        if(R[i] != 0){
            if(R[i] % 2 == 1){
                ans[R[i] + i - 1]++;
            }else{
                ans[R[i] + i]++;
            }
        }
    }
    for (int i = N - 1; i > 0;i--){
        if(L[i] != 0){
            if(L[i] % 2 == 1){
                ans[i - L[i]+1]++;
            }else{
                ans[i - L[i]]++;
            }
        }
    }

    for (int i = 0; i < N;i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3072
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    int[] ss, cs;
    foreach (_; 0..M) {
        auto sc = readln.split;
        ss ~= sc[0].to!int-1;
        cs ~= sc[1][0];
    }

    foreach (n; 0..1000) {
        auto x = n.to!string;
        if (x.length != N) continue;
        bool ok = true;
        foreach (i; 0..M) {
            if (x[ss[i]] != cs[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            writeln(x);
            return;
        }
    }
    writeln(-1);
}

Measured memory_bytes: 256
#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 A, B, C, K;
  cin >> A >> B >> C >> K;
  int max = 0;

  if (A > K) {
    max += K;
    cout << max << endl;
    return 0;
  }
  max += A;
  K -= A;

  if (B > K) {
    cout << max << endl;
    return 0;
  }
  K -= B;

  max -= K;
  cout << max << endl;
}


Measured memory_bytes: 3600
N = int(input())
sub = 0
count = 1
A = [int(i) for i in input().split()]
if N > 1:
	pre_num = A[1]
	pre_sub = A[1] - A[0]
for num in A[2:]:
    if not pre_num == num:
        if pre_sub * (num - pre_num) < 0:
            count += 1
            pre_sub = 0
        else:
          	pre_sub = num - pre_num
        pre_num = num
print(count)

Measured memory_bytes: 14252
#define _USE_MATH_DEFINES
#include <cstdio>
#include <math.h>

struct Point {
	double x;
	double y;
};

void koch(int n, const Point &a, const Point &b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI*60.0 / 180.0;

	s.x = (2.0 *a.x + 1.0*b.x) / 3.0;
	s.y = (2.0*a.y + 1.0*b.y) / 3.0;
	t.x = (1.0*a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main() {
	int n = 0;
	scanf("%d", &n);
	Point pt1 = { 0 };
	Point pt2 = { 100,0 };
	printf("%.8f %.8f\n", pt1.x, pt1.y);
	koch(n, pt1, pt2);
	printf("%.8f %.8f\n", pt2.x, pt2.y);
	return 0;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
#define int long long
//#define double long double

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, t, cnt[200001] = {};
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> t, v.push_back(t), cnt[t]++;

    int sum = 0;
    for (int i = 1; i <= n; i++)
        sum += cnt[i] * (cnt[i] - 1) / 2;

    for (int i : v)
        cout << sum - cnt[i] * (cnt[i] - 1) / 2 + (cnt[i] - 1) * (cnt[i] - 2) / 2 << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 5872
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

ll n, k;
string s;

int main()
{
  cin >> s;
  ll af, ze;

  af = s.find_first_of('A');
  ze = s.find_last_of('Z');

  cout << ze - af + 1 << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

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

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

const ll nmax=1000000;


ll fac[nmax],finv[nmax],inv[nmax];

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(ll i=2;i<nmax;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;
}
}

auto com(auto n, auto k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}



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

 ll n;
  cin >> n;
 vpll pos(n+1);
  rep(i,0,n+1) {
    cin >> pos[i].first;
    pos[i].second=i;
  }
  sort(pos.begin(),pos.end());
  
  ll l,r;
  rep(i,0,n) if(pos[i].first==pos[i+1].first) {
   l=pos[i].second;
   r=pos[i+1].second;
    break;
  }
  
  comint();
  
  rep(k,1,n+2) cout << (com(n+1,k)-com(l+n-r,k-1)+mod)%mod << endl;
  

}



Measured memory_bytes: 26240
import math
a=input()
b=a.split()
b=list(map(int,b))
i = [input() for i in range(b[0])]
for o in range(b[0]):
    i[o]=i[o].split()
    i[o]=list(map(int,i[o]))
f=0
for p in range(b[0]-1):
    for g in range(b[0]-p-1):
        h=g+p+1
        c=0
        for j in range(b[1]):
            c+=(i[p][j]-i[h][j])*(i[p][j]-i[h][j])
        d=math.sqrt(float(c))
        if (d-int(d))==0:
            f+=1
print(f)


Measured memory_bytes: 3064