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

using namespace std;

int n;
bool st[10];

struct e
{
    int x,y;
}e[10];

double res = 0;

void dfs(int k,int q,double w)
{
    if(k == n - 1)
    {
        res += w;
        return ;
    }


    for(int i = 0;i < n;i++)
    {
        if(!st[i])
        {
            w += sqrt(abs((e[i].x - e[q].x) * (e[i].x - e[q].x) + (e[i].y - e[q].y) * (e[i].y - e[q].y)));
            //cout << "hhh" << res << "   " << endl;
            st[i] = true;
            //cout << i << " ... ";
            dfs(k + 1,i,w);
            w -= sqrt(abs((e[i].x - e[q].x) * (e[i].x - e[q].x) + (e[i].y - e[q].y) * (e[i].y - e[q].y)));
            st[i] = false;
        }
    }
}

int main()
{
    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> e[i].x >> e[i].y;

    for(int i = 0;i < n;i++)
    {
        st[i] = true;
        //cout << i << " -- ";
        dfs(0,i,0);

        st[i] = false;
    }

    for(int i = 2;i <= n;i++)
        res /= i;

    printf("%.6f",res);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<string>A(N);
    rep(i, N){
        cin >> A.at(i);
    }
    vector<pair<ll, ll>> B(N);
    rep(i, N){
        ll c = 0;
        ll p = 0;
        rep(j, sz(A.at(i))){
            if(A.at(i).at(j) == '.'){
                c = sz(A.at(i)) - j - 1;
                p = j;
                break;
            }
        }
        if(p != 0){
            ll x = stoll(A.at(i).substr(0, p)+A.at(i).substr(p+1));
            B.at(i) = make_pair(pow(10, c), x);
        }
        else{
            B.at(i) = make_pair(1, stoll(A.at(i)));
        }
    }
    vector<pair<ll, ll>> C(N);
    rep(i, N){
        ll g = gcd(B.at(i).first, B.at(i).second);
        C.at(i) = make_pair(B.at(i).first/g, B.at(i).second/g);
    }
    vector<pair<ll, ll>> D(N);
    rep(i, N){
        ll a = 0;
        ll b = 0;
        ll c = 0;
        ll d = 0;
        ll s = C.at(i).first;
        ll t = C.at(i).second;
        while(s % 2 == 0){
            a++;
            s /= 2;
        }
        while(s % 5 == 0){
            b++;
            s /= 5;
        }
        while(t % 2 == 0){
            c++;
            t /= 2;
        }
        while(t % 5 == 0){
            d++;
            t /= 5;
        }
        D.at(i) = make_pair(c-a, d-b);
    }
    sort(all(D));
    map<pair<ll, ll>, ll> cnt;
    rep(i, N){
        cnt[D.at(i)]++;
    }
    ll ans = 0;
    rep2(i, -9, 45){
        rep2(j, -9, 45){
            rep2(k, -9, 45){
                rep2(l, -9, 45){
                    if((i + k) < 0 || (j + l) < 0){
                        continue;
                    }
                    if(i == k && j > l){
                        continue;
                    }
                    if(i > k){
                        continue;
                    }
                    if(i == k && j == l){
                        ans += (cnt[make_pair(i, j)] * (cnt[make_pair(i, j)]-1)) / 2;
                    }
                    else{
                        ans += cnt[make_pair(i, j)] * cnt[make_pair(k, l)];
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19392
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define ld long double
using namespace std;
int32_t main()
{
    IOS;
    int a;
    cin>>a;
    int ans = a + (a*a)+(a*a*a);
    cout << ans << endl;
  }

Measured memory_bytes: 3700
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

template <class Integer>
auto boost_irange(Integer last) { return boost::irange(static_cast<Integer>(0), last); }
template <class Integer>
auto boost_irange(Integer first, Integer last) { return boost::irange(first, last); }

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }
};

int main()
{
    input in;
    output out;

    std::string s;
    in >> s;

    std::vector<int> res(s.size());
    s.push_back(' ');

    int l = 0, count = 1;
    char prev = 'R';
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == prev) {
            ++count;
            continue;
        }
        if (prev == 'R') {
            res[i] += count / 2;
            res[i - 1] += count / 2 + count % 2;
            prev = 'L';
            count = 1;
            l = i;
        } else {
            res[l - 1] += count / 2;
            res[l] += count / 2 + count % 2;
            prev = 'R';
            count = 1;
        }
    }

    for (int x : res) {
        std::cout << x << " ";
    }

    return 0;
}


Measured memory_bytes: 1104
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int n,m;
int v[100001];
int check[100001];
struct graph{
    int f = 0;
    int x;
    vector <int> e;
    vector <int> w;
};
vector <struct graph> g;
int l,r,d;

bool dfs(int i){
    int j;
    int s = g[i].e.size();
        for(int k=0;k<s;k++){
            j = g[i].e[k];
            if(g[j].f == 1){
                if(g[j].x - g[i].x == g[i].w[k]){
                    continue;
                }else{
                    return false;
                }
            }

            if(g[j].f == 0){
                g[j].x = g[i].x + g[i].w[k];
                g[j].f = 1;
                if(!dfs(j)) return false;
            }                
        }
    return true;
}

int main(void){
    cin >> n >> m;
    g.resize(n+1);

    for(int i=1;i<=m;i++){
            cin >> l >> r >> d;
            g[l].e.push_back(r);
            g[l].w.push_back(d);
            g[r].e.push_back(l);
            g[r].w.push_back(-d);
    }

    for(int i=1;i<=n;i++){
        if(g[i].f == 0){g[i].x = 0; g[i].f = 1;}
        if(!dfs(i)){cout << "No"; return 0;}
    }

    cout << "Yes";
    return 0;
}

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

using namespace std;

typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	int a, b;
	
	cin >> a >> b;
	
	if(a >= 13){
		cout << b << endl;
	}
	else if(a >= 6 && a <= 12){
		cout << b / 2 << endl;
	}
	else{
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


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

	string s;
	cin >> s;
	int p, g;
	p = g = 0;
	int w = 0;
	for (char c : s) {
		if (c=='p') {
			if (p < g) {
				p++;
			}
			else {
				g++;
				w--;
			}
		}
		else {
			if (p < g) {
				p++;
				w++;
			}
			else g++;
		}

	}
	cout << w << endl;

	return 0;
}

Measured memory_bytes: 512
(defun split (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(destructuring-bind (x y) (mapcar #'parse-integer (split (read-line)))
  (format t "~a~%"
          (if (loop :for group in '((1 3 5 7 8 10 12)
                                    (4 6 9 11)
                                    (2))
                    :thereis (and (member x group)
                                  (member y group)))
              "Yes" "No")))
          


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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ans=10000;
    int n=s.length();
    int m=t.length();
    int c=0;
    for(int i=0;i<n-m+1;i++)
    {
         for(int j=0;j<m;j++)
         {
              if(s[i+j]!=t[j])
              c++;
         }
         ans=min(ans,c);
         c=0;
    }
    cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3596
n, k = map(int , input().split())
h = list(map(int, input().split()))
count = 0
MOD = 1000000007
h.sort()
try:
    if(k != 0):
        del h[-k]
    for i in range(n - k):
        count += h[i]%MOD
    print(count)
except IndexError:
    count = 0
    print(count)


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

int main() {
	// your code goes here
	int n,l,i;
	cin>>n>>l;
	string s[n],t;
	for(i=0;i<n;i++)
	{
	    cin>>s[i];
	}
	sort(s,s+n);
	for(i=0;i<n;i++)
	{
	    t+=s[i];
	}
	cout<<t<<endl;
}


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

/**
 * Created by S64 on 15/07/25.
 */
public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int input = Integer.parseInt( reader.readLine() );
        System.out.println((int) Math.pow(input, 3));
    }

}

Measured memory_bytes: 16872
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

long long gcd(long long a, long long b){
  	long long M = std::max(a, b);
  	long long m = std::min(a, b);
  	if(M%m==0) return m;
  	return gcd(M%m, m);
}

int main(){
  	int n;
  	long long k;
  	std::cin >> n >> k;
  	std::vector<long long> a(n);
  	
  	bool abs1 = false;
  	std::cin >> a.at(0);
  	long long max = a.at(0);
  	long long prev = a.at(0);
  	if(a.at(0)==k){
         std::cout << "POSSIBLE" << "\n";
         return 0;
    }
  	bool;
  	for(int i=1;i<n;i++){
      	auto& e = a.at(i);
      	std::cin >> e;
      	long long g = gcd(prev, e);
      	if(k%g==0){
          	abs1=true;
        }
      	if(e==k){
          	std::cout << "POSSIBLE" << "\n";
          	return 0;
        }
      	if(g==1){
          	abs1=true;
        }
      	max = std::max(max, e);
      	prev = e;
    }
  	if(max > k && abs1){
      	std::cout << "POSSIBLE" << "\n";
    }else{
      	std::cout << "IMPOSSIBLE" << "\n";
    }
  	return 0;
}

Measured memory_bytes: 3512
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long x = sc.nextLong(); long k = sc.nextLong(); long d = sc.nextLong();
        long mod = x % d;
        if (mod < 0) mod += d;
        if (mod == 0) {
            long times = Math.abs(x - mod) / d;
            if (times <= k) {
                out.println(((times - k) % 2 == 0 ? 0 : d));
            }
            else if (x < 0) {
                out.println(Math.abs(x + k * d));
            } else {
                out.println(Math.abs(x - k * d));
            }
        } else {
            long other = mod - d; long reach;
            if (Math.abs(other) < mod) reach = other; reach = mod;
            long times = Math.abs(reach - x) / d;
            if (times <= k) {
                out.println((times - k) % 2 == 0 ? Math.abs(reach) : (d - Math.abs(reach)));
            }
            else if (x < 0) {
                out.println(Math.abs(x + k * d));
            } else {
                out.println(Math.abs(x - k * d));
            }
        }
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 32928
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n1,n2,dp[3100][3100];
char s[3005],t[3005];
string ty;
int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	n1=strlen(s+1);
	n2=strlen(t+1);
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			int tt=max(dp[i-1][j],dp[i][j-1]);
			if(s[i]==t[j]) { tt=max(tt,dp[i-1][j-1]+1) ;}
			dp[i][j]=tt;
		}
	}
	int x=n1,y=n2;
	//int cev=dp[n1][n2];
	while(x>0 && y>0){
		if(s[x]==t[y]){
			ty=ty+s[x];
			x--;
			y--;
		}
		else if(dp[x-1][y]>dp[x][y-1]){
			x--;
		}
		else y--;
	}
	reverse(ty.begin(),ty.end());
	cout<<ty<<endl;
	return 0;
}




Measured memory_bytes: 37120
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

const int N=2200;
ll int dp[N][N];
ll int ncr(ll int n, ll int r)
{
	if(n==r)
		return 1;
	if(r==1)
		return n;
	if(n<r || n<0 || r<0)
		return 0;
	if(dp[n][r]!=-1)
		return dp[n][r];
	else 
		return dp[n][r]=(ncr(n-1,r-1)+ncr(n-1,r))%mod;
}

int32_t main()
{
 
memset(dp,-1,sizeof dp);
ll int n,k;
cin>>n>>k;
ll int red=n-k;
for(ll int i=1;i<=k;i++)
{
	cout<<(ncr(red+1,i)*ncr(k-1,i-1))%mod<<"\n";
}
return 0;
}

Measured memory_bytes: 38144
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>
#include<stack>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef unsigned long long  ll;

#define MOD 1000000007



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

	if(a+b+c>=22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
from itertools import combinations

n = int(input())
names = [input() for _ in range(n)]

march = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for name in names:
    if name[0] in march:
        march[name[0]] += 1

res = 0
for c in combinations(march, 3):
    res += march[c[0]] * march[c[1]] * march[c[2]]

print(res)

Measured memory_bytes: 9772
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, K;
    cin >> N >> K;

    vector<int> v(N + 1);
    REP(i, N) {
        int tmp;
        cin >> tmp;
        v[tmp]++;
    }


    SORT(v);
    int cnt = count_if(ALL(v), [](int a) {return a > 0; });
    int ans = 0;
    auto f = find_if(ALL(v), [](int a) {return a > 0; });
    FOR(i, 0, N + 1) {
        if (v[i] == 0)continue;
        if (cnt <= K)break;
        cnt--;
        ans += v[i];
    }

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

Measured memory_bytes: 1024
#include<cstdio>
int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",n*(n-1)/2-n/2);
  for(int i=2;i<=n;i++){
    for(int j=1;j<i;j++){
      if(i+j!=n+1-n%2)printf("%d %d\n",j,i);
    }
  }
  return 0;
}

Measured memory_bytes: 128
import numpy as np

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
f = np.zeros((h+2, w+2), dtype='int64')
d = np.ones((3, 3), dtype='int64')

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            f[i:i+3, j:j+3] += d 

for i in range(h):
    ans = ''
    for j in range(w):
        if s[i][j] == '#':
            ans += '#'
        else:
            ans += str(f[i+1, j+1])
    print(ans)

Measured memory_bytes: 12428
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100009;
ll dist[N];
vector< vector< pair<int,int> > > v(N);
bool vis[N];
void dfs(int no,int p,ll co)
{
    dist[no]=co;
    vis[no]=1;
    for(int i=0;i<sz(v[no]);i++)
    {
        int nw=v[no][i].first;
        int we=v[no][i].second;
        if(vis[nw])
            continue;
        dfs(nw,no,co+we);
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        v[a].pb(mp(b,c));
        v[b].pb(mp(a,c));
    }
    int q,k;
    cin>>q>>k;
    dfs(k,0,0);
    while(q--)
    {
        int fr,to;
        cin>>fr>>to;
        cout<<dist[fr]+dist[to]<<endl;
    }
}




Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define ll long long
#define Mod 1000000007
#define M 200005
using namespace std;
int n,A[M],las[M],W[M],dp[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		las[i]=W[A[i]];
		W[A[i]]=i;
//		cerr<<i<<" "<<las[i]<<endl;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=dp[i-1];
		if(las[i]&&i-las[i]>1){
			dp[i]=(dp[i]+dp[las[i]])%Mod;
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 3328
# https://atcoder.jp/contests/abc070/tasks/abc070_b

A, B, C, D = map(int, input().split())

if A >= C:
    start = A
else:
    start = C

if B >= D:
    end = D
else:
    end = B

ans = end - start
if ans < 0:
    ans = 0

print(ans)

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

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

void solve() {
    int N; cin >> N;
    vector<int> X(N); rep(i, N) cin >> X[i];

    int sum = accumulate(X.begin(), X.end(), 0);
    int candidate_idx = ceil(sum / (float) N);

    int ans1 = 0;
    rep(i, N){
        ans1 += pow((candidate_idx - X[i]), 2);
    }

    --candidate_idx;

    int ans2 = 0;
    rep(i, N){
        ans2 += pow((candidate_idx - X[i]), 2);
    }

    cout << ((ans1 < ans2) ? ans1 : ans2) ;
    cout << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db double
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=5e5+10,M=3e4+10;
const ll inf=INT_MAX,mod=1e9+7;
const db pi=atan(1)*4;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a)%mod; a=(a*a)%mod; b/=2; } return s;}
ll lcm(ll a,ll b) {return a/__gcd(a,b)*b; }
int read()
{
    int s=0,f=1; char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();} return s*f;
}

typedef struct as
{
    int l,r,pos;
    bool operator <(const as &t) const
    {
        return l<t.l;
    }
}as;

int num[N];
void add(int pos,int x)
{
    while(pos<N){
        num[pos]+=x;
        pos+=pos&-pos;
    }
}
int sum(int x)
{
    int s=0;
    while(x){
        s+=num[x];
        x-=x&-x;
    }
    return s;
}

as t[N];
int n,q,a[N],pre[N],nex[N],vis[N],ans[N];

int main()
{
    iosks;
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=q;i++) cin>>t[i].l>>t[i].r,t[i].pos=i;sort(t+1,t+q+1);
    for(int i=n;i>=1;i--){
        if(!pre[a[i]]) pre[a[i]]=i,vis[i]=1;
        else nex[i]=pre[a[i]],vis[nex[i]]=0,vis[i]=1,pre[a[i]]=i;
    }
    for(int i=1;i<=n;i++) if(vis[i]) add(i,1);
    int l=1;
    for(int i=1;i<=q;i++){
        for(;l<t[i].l;l++){
            if(vis[l]){
                add(l,1),vis[l]=0;
                if(nex[l]) vis[nex[l]]=1,add(nex[l],1);
            }
        }
        ans[t[i].pos]=sum(t[i].r)-sum(t[i].l-1);
    }
    for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 20764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<ll> a(N);
	rep(i,N) cin >> a[i];
	V<ll> b(N);
	rep(i,N){
		if(i%2 == 0) b[0] += a[i];
		else b[0] -= a[i];
	}
	b[0] /= 2;
	rep1(i,N-1) b[i] = a[i-1] - b[i-1];
	rep(i,N) cout << b[i]*2 << " ";
	cout << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;

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

int h, w;
char field[410][410];

vector<P>tmp;
bool used[410][410];

int black = 0; int white = 0;
void dfs(int x, int y) {
	used[x][y] = true;
	if (field[x][y] == '#')black++;
	else white++;
	rep(i, 8) {
		int nx = x + dx[i]; int ny = y + dy[i];
		if (0 <= nx && nx < h && 0 <= ny && ny < w) {
			if (!used[nx][ny] && field[x][y] != field[nx][ny])dfs(nx, ny);
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> field[i][j];
	rep(i, h) {
		rep(j, w) {
			if (field[i][j] == '#') {
				tmp.push_back(make_pair(i, j));
			}
		}
	}
	int ans = 0;
	rep(i, tmp.size()) {
		if (used[tmp[i].first][tmp[i].second]) {
			continue;
		}
		black = 0; white = 0;
		dfs(tmp[i].first, tmp[i].second);
		ans += black * white;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9456
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		long c = parseLong(sc.next());
		long k = parseLong(sc.next());
		sc.close();
		long ans=0;
		ans=Math.min(a, k);
		k=Math.max(k-a-b, 0);
		if(k>0) {
			ans-=Math.min(c, k);
		}
		out.println(ans);
	}
}


Measured memory_bytes: 27004
import sys
import collections
import itertools

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def grouper(self):
        import itertools
        import operator
        par = operator.itemgetter(1)
        for _, group in itertools.groupby(
                sorted(enumerate(self.par), key=par), par):
            yield [i for i, par in group]

def sliding_window(n, seq):
    import collections
    import itertools
    return zip(*(collections.deque(itertools.islice(it, i), 0) or it
               for i, it in enumerate(itertools.tee(seq, n))))

Edge = collections.namedtuple('Edge', ['s', 't', 'cost'])

N = int(sys.stdin.readline())
xys = [[i] + list(map(int, line.split())) for i, line in enumerate(sys.stdin)]
edges = []
for (i1, x1, _), (i2, x2, _) in sliding_window(2, sorted(xys, key=lambda t: t[1])):
    edges.append(Edge(i1, i2, abs(x1 - x2)))
for (i1, _, y1), (i2, _, y2) in sliding_window(2, sorted(xys, key=lambda t: t[2])):
    edges.append(Edge(i1, i2, abs(y1 - y2)))
edges = sorted(edges, key=lambda e: e.cost)
uf = UnionFind(N)
min_cost = 0
for edge in edges:
    if not uf.are_same(edge.s, edge.t):
        uf.union(edge.s, edge.t)
        min_cost += edge.cost
print(min_cost)

Measured memory_bytes: 54216
n = int(input())
result = []
for i in range(0, n):
    temp_value = input()
    result.append(temp_value)
print('AC x ' + str(result.count('AC')))
print('WA x ' + str(result.count('WA')))
print('TLE x ' + str(result.count('TLE')))
print('RE x ' + str(result.count('RE')))


Measured memory_bytes: 16220
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>


using namespace std;

typedef long long ll;
int a[200010];
bool compare(int a,int b)
{
    return a>b;
}
int main()
{
    int n,k,x;
    cin>>n>>k;
    memset(a,0,sizeof(a));
    for(int i=0; i<n; i++)
    {
        cin>>x;
        a[x]++;
    }
    int ans=0;
    sort(a,a+n,compare);
    for(int i=k; i<=n; i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1152
import math

nd = [int(i) for i in input().split()]
x = []
for i in range(nd[0]):
    tmp = [int(i) for i in input().split()]
    x.append(tmp)
result = 0
for i in range(nd[0]):
    for j in range(i+1, nd[0]):
        before_root = 0
        for k in range(len(x[0])):
            before_root += (x[i][k] - x[j][k])**2
        if math.sqrt(before_root).is_integer():
            result += 1
print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long a , b , c , d;
        cin >> a >> b >> c >> d;
        if(a + b < c + d ){
            cout << "Right" << endl;
        }else if(a + b > c + d){
            cout << "Left" << endl;
        }else{
            cout << "Balanced" << endl;
        }
        
        return 0;
    }

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

using namespace std;
typedef long long ll;

// #define DEBUG

class Unionfind
{
    vector<int> p;

public:
    Unionfind(int n);
    int find(int x);
    void unite(int x, int y);
    bool match(int x, int y);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}

int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

bool Unionfind::match(int x, int y)
{
    return (find(x) == find(y)) ? true : false;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}

void printsubset(int x)
{
    int t;
    cout << x << ":";
    t = 0;
    while (x > 0)
    {
        if (x % 2 == 1)
            cout << " " << t;
        x /= 2;
        t++;
    }
    cout << endl;
}

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, q, t, s, x, op;
    cin >> n >> q;
    list<int> a[n];
    for (int i = 0; i < q; i++)
    {
        cin >> op;
        if (op == 0)
        {
            cin >> t >> x;
            a[t].push_back(x);
        }
        else if (op == 1)
        {
            cin >> t;
            for (auto itr = a[t].begin(); itr != a[t].end(); itr++)
            {
                if (itr != a[t].begin())
                    cout << " ";
                cout << *itr;
            }
            cout << endl;
        }
        else if (op == 2)
        {
            cin >> s >> t;
            a[t].splice(a[t].end(), a[s]);
        }
    }

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 18728
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << (char)(a[0] - 32) << (char)(b[0] - 32) << (char)(c[0] - 32) << endl;
	return 0;
}

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

int main(){
  int i,j,N,M,k,p,ans=0;
  cin>>N>>M;
  vector<int> v(M,0);
  for(i=0;i<N;i++){
    cin>>k;
    for(j=0;j<k;j++){
      cin>>p;
      v[p-1]++;
    }
  }
  for(i=0;i<M;i++){
    if(v[i]==N)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

		boolean[] s = new boolean[13];
		boolean[] h = new boolean[13];
		boolean[] c = new boolean[13];
		boolean[] d = new boolean[13];
		for(int i = 0; i < 13 ; i++){
			s[i] = false;
			h[i] = false;
			c[i] = false;
			d[i] = false;
		}

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		char ch;
		for(int i = 0; i < n; i++){
			ch = scan.next().charAt(0);
			int number = scan.nextInt();
			switch(ch){
				case 'S' :
					s[number - 1] = true;
					break;
				case 'H' :
					h[number - 1] = true;
					break;
				case 'C' :
					c[number - 1] = true;
					break;
				case 'D' :
					d[number - 1] = true;
					break;
				default :
					break;
			}
		}

		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				switch(i){
					case 0 :
						if(s[j] == false){
							System.out.printf("S %d\n", j + 1);
						}
						break;
					case 1 :
						if(h[j] == false){
							System.out.printf("H %d\n", j + 1);
						}
						break;
					case 2 :
						if(c[j] == false){
							System.out.printf("C %d\n", j + 1);
						}
						break;
					case 3 :
						if(d[j] == false){
							System.out.printf("D %d\n", j + 1);
						}
				}
			}
		}
	}
}

Measured memory_bytes: 26480
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, M, V, P, A[100000]; cin >> N >> M >> V >> P;
  REP(i, N) cin >> A[i];
  sort(A, A+N);

  int left = -1, right = N-P;
  while(right-left > 1){
    int mid = (left+right) / 2;
    bool ok = 1;
    if(A[mid]+M < A[N-P]) ok &= 0;
    int remain = M*(V-mid-1-P+1);
    int sum = 0;
    for(int i = mid+1; i <= N-P; i++){
      sum += min(M, A[mid]+M-A[i]);
    }
    if(remain > sum) ok &= 0;

    if(ok) right = mid;
    else left = mid;
  }
  cout << N - right << endl;
}

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

int main(){
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    if (a.size() == 1) cout << abs(w - a[0]) << endl;
    else cout << max(abs(w - a.back()), abs(a[n-1] - a[n-2]));   
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
struct me{
    int x,y;
}a[105],b[105];
bool f[105];
bool cmp1(struct me v1,struct me v2){
    return v1.y>v2.y;
}
bool cmp2(struct me v1,struct me v2){
    return v1.x<v2.x;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].y);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&b[i].x,&b[i].y);
    stable_sort(a+1, a+1+n, cmp1);
    stable_sort(b+1, b+1+n, cmp2);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(f[j]==false&&a[j].x<b[i].x&&a[j].y<b[i].y){
                f[j]=true;
                break;
            }
        }
    }
    int s=0;
    for(int i=1;i<=n;i++)
        if(f[i]==true)
            s++;
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

as = gets.split.map &:to_i

count = 0
result = []

n.downto(1){ |x|
	(x * 2).step(n, x){ |i|
		as[x - 1] ^= as[i - 1]
	}
	
	if as[x - 1] == 1 then
		result << x
		count += 1
	end
}

puts count
puts result.sort.join(" ")


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  if(s == "Sunny") cout << "Cloudy" << endl;
  if(s == "Cloudy") cout << "Rainy" << endl;
  if(s == "Rainy") cout << "Sunny" << endl;


  return 0;
}


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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;

    vector<int> score(N);

    for (int i = 0; i < N; i++) {
        cin >> score.at(i);
    }

    int max = 0;
    for (int i =0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            max += score.at(i) * score.at(j);
        }
    }

    cout << max << endl;
    return 0;
}


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

int kaku_keta_wa(int N);

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

	if (N%(kaku_keta_wa(N)) == 0) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
	return 0;
}

int kaku_keta_wa(int N) {
	int M, sum = 0;
	while (N) {
		M = N % 10;
		sum += M;
		N = N / 10;
	}
	return sum;
}


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


int main() {
  string S;
  cin >> S;
  
  if(S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
  
}


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

constexpr ll INFI = 1e18;

ll calc(int n, int k, vector<int> v, int* a);

int main() {
	int n, k;
	ll lcost;
	ll cost;
	cin >> n >> k;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	vector<int> v;
	v.push_back(0);
	cout << calc(n, k, v, a) << endl;

}

ll calc(int n, int k, vector<int> v, int* a) {
	if (v.size() == k) {
		int index = 0;
		int height = 0;
		ll cost = 0;
		for (int i = 0;index<k;i++) {
			if (v[index] == i) {
				if (a[i] > height) {
					height = a[i];
				}
				else {
					height++;
					cost += height - a[i];
				}
				index++;
			}
			else {
				if (a[i] > height) {
					height = a[i];
				}
			}
		}
		return cost;
	}else {
      	ll mi=INFI;
		for (int i = v[v.size() - 1] + 1;i < n;i++) {
			vector<int> v2(v);
			v2.push_back(i);
			mi = min(mi,calc(n, k, v2, a));
		}
		return mi;
	}
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))

sumn = 0
ruiseki = {}
ruiseki[sumn] = 1
for i in range(N):
    sumn += A[i]
    if sumn%M not in ruiseki.keys():
        ruiseki[sumn%M] = 0
    ruiseki[sumn%M] += 1

ans = 0
for v in ruiseki.values():
    ans += v*(v-1)/2
print(int(ans))


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> h(n); rep(i,n) cin >> h[i];

  int ans = 0;
  int tmp = 0;
  rep(i,n-1){
    if(h[i]>=h[i+1]) tmp++;
    else tmp = 0;
    ans = max(ans,tmp);
  }

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


Measured memory_bytes: 3736
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;
string s;

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

  scan(n); scan(s);
  vint r(n);
  int cnt = 0;
  int ans = n/2;

  if(s[0]=='#') r[0]=1;
  else          r[0]=0;
  FOR(i, 1, n){
    if(s[i]=='#') r[i] = r[i-1]+1;
    else          r[i] = r[i-1];
  }
  ans = n-r[n-1];
  FOR(i, 1, n+1){
    cnt = r[i-1] + n-i-(r[n-1]-r[i-1]);
    ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
int m,f,r;
int main()
{
    while (1>0)
    {
        scanf("%d%d%d",&m,&f,&r);
        if (m==-1 && f==-1 && r==-1) return 0;
        if (m==-1 || f==-1 || m+f<30)
            printf("F\n");
        else
            if (m+f>=80) printf("A\n");
            else
                if (m+f>=65) printf("B\n");
                else
                    if (m+f>=50) printf("C\n");
                    else
                        if (m+f>=30)
                        {
                            if (r>=50) printf("C\n");
                            else printf("D\n");
                        }
    }
}



Measured memory_bytes: 3164