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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string a, b;
    cin >> a >> b;

    if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else {
        int f = 0;
        rep(i, a.size()) {
            if (a[i] < b[i]) {
                f = -1;
                break;
            } else if (a[i] > b[i]) {
                f = 1;
                break;
            }
        }
        if (f == -1) {
            cout << "LESS" << endl;
        } else if (f == 1) {
            cout << "GREATER" << endl;
        } else {
            cout << "EQUAL" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
ll n;
//-------------------関数----------------------//

ll r[200];
ll m, R;
ll f[305][305] = {};
void floyd()
{
	for (int k = 0; k < n; ++k)
	{
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
				f[j][i] = f[i][j];
			}
		}
	}
	return;
}
int main() {
	cin >> n >> m >> R;
	fill_all(f, (ll)INF);
	REP(i, R) { cin >> r[i]; r[i]--; }
	REP(i, m) {
		ll a, b, c; cin >> a >> b >> c; a--, b--;
		f[a][b] = c; f[b][a] = c;
	}
	floyd();
	ll izryt = INF;
	sort(r, r + R);
	do {
		ll cnt = 0;
		REP(i, R-1) {
			cnt+=f[r[i]][r[i + 1]];
		}
		izryt = min(izryt, cnt);
	} while (next_permutation(r, r + R));
	cout << izryt << endl;
	return 0;
}


Measured memory_bytes: 1656
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int h, w;
int a, b;

int board[1010][1010];
int colCount[1010];

bool isAccepted;

int main()
{
	scanf("%d%d", &h, &w);
	scanf("%d%d", &a, &b);
	
	if (a > (w / 2))
	{
		printf("-1\n");
		return 0;
	}
	
	if (b > (h / 2))
	{
		printf("-1\n");
		return 0;
	}
	
//	memset(colCount, 0, sizeof(colCount));
//	isAccepted = true;
//	for (int r = 0 ; r < h ; r++)
//	{
//		int left = a;
//	}

	for (int r = 1 ; r <= b ; r++)
		for (int c = 1 ; c <= a ; c++)
			board[r][c] = 1;

	for (int r = b + 1 ; r <= h ; r++)
		for (int c = a + 1 ; c <= w ; c++)
			board[r][c] = 1;

	
	
//	if (isAccepted)
//	{
		for (int r = 1 ; r <= h ; r++)
		{
			for (int c = 1 ; c <= w ; c++)
				printf("%d", board[r][c]);
			printf("\n");
		}
//	}
	
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int scc(const VV<>& g, V<>& comp) {
  int n = g.size();
  VV<> rg(n);
  for (int v = 0; v < n; v++) {
    for (int w : g[v]) {
      rg[w].push_back(v);
    }
  }
  V<> vs;
  V<bool> vis(n);
  comp.resize(n);

  auto dfs = [&](const auto& dfs, int v) -> void {
    vis[v] = true;
    for (int w : g[v]) if (!vis[w]) {
      dfs(dfs, w);
    }
    vs.push_back(v);
  };

  auto rdfs = [&](const auto& rdfs, int v, int k) -> void {
    vis[v] = true;
    comp[v] = k;
    for (int w: rg[v]) if (!vis[w]) {
      rdfs(rdfs, w, k);
    }
  };

  for (int v = 0; v < n; v++) if (!vis[v]) {
    dfs(dfs, v);
  }
  vis.assign(n, false);
  int k = 0;
  reverse(vs.begin(), vs.end());
  for (int v : vs) if (!vis[v]) {
    rdfs(rdfs, v, k++);
  }
  return k;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VV<> g(n);
  for (int i = 0; i < n - 1 + m; ++i) {
    int a, b; cin >> a >> b, --a, --b;
    g[a].push_back(b);
  }
  V<> comp;
  int k = scc(g, comp);
  assert(k == n);
  V<> vs(n);
  iota(begin(vs), end(vs), 0);
  sort(begin(vs), end(vs), [&](int u, int v) { return comp[u] < comp[v]; });
  for (int v = 0; v < n; ++v) {
    sort(begin(g[v]), end(g[v]), [&](int ul, int ur) { return comp[ul] < comp[ur]; });
  }
  V<> par(n, -2);
  auto dfs = [&](const auto& dfs, int v, int p) -> void {
    if (par[v] != -2) return;
    for (int w : g[v]) if (w != p) {
      dfs(dfs, w, v);
    }
    par[v] = p;
  };
  dfs(dfs, vs[0], -1);
  for (int v = 0; v < n; ++v) {
    cout << par[v] + 1 << '\n';
  }
}

Measured memory_bytes: 13952
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t A, B, K;

	scanf("%zu %zu %zu", &A, &B, &K);

	size_t val = MIN(A, B);

	for (size_t count = 0; count < K; count++) {
		while (true) {
			if (A%val == 0 && B%val == 0) {
				val--;
				break;
			}

			val--;
		}
	}

	printf("%zu\n", val+1);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define buff ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define xy pair<int, int>
#define x first
#define y second 

#define inf std::numeric_limits<int>().max()

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (s*t >= d) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3140
// darksta5's template v2.0

#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back
#define del erase
#define sz size
#define ins insert
#define FOR(a,b,c) for(int a = b; a < c; a++)
#define FORS(a,b,c) for(int a = b; a <= c; a++)
#define FORN(a,b) for(int a = 0; a < b; a++)
#define FORD(a,b,c) for (int a = b; a >= c; a--)
#define RES(a,b) memset(a,b,sizeof(a))
#define LL long long
#define PI acos(-1)
#define eps 1e-9
#define MOD 1000000007
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;
  if ((s.sz() % 2 == 0) ^ (s[0] == s[s.sz()-1])) {
    cout << "Second" << endl;
    return 0;
  }

  cout << "First" << endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	FOR(i,0,n){
		if(i % 2 == 0 && s[i] == 'p')ans--;
		if(i % 2 == 1 && s[i] == 'g')ans++;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;

class Program {
    static void Main() {
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = n[0];
        int b = n[1];
        if (a < b) {
            Console.WriteLine("a < b");
        } else if (a > b) {
            Console.WriteLine("a > b");
        } else {
            Console.WriteLine("a == b");
        }
    }
}


Measured memory_bytes: 9360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
     
    public static void CountingSort(int[] A, int[] B, final int n, final int k){
        int[] C = new int[k];
        for(int i = 0; i < k; i++){
            C[i] = 0;
        }
         
        for(int i = 0; i < n; i++){
            C[A[i]]++;
        }
         
        for(int i = 1; i < k; i++){
            C[i] += C[i - 1];
        }
         
        for(int i = n - 1; i >= 0; i--){
            B[C[A[i]] - 1] = A[i];
            C[A[i]]--;
        }
    }
     
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
         
        final int n = sc.nextInt();
        int[] array = new int[n];
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
            max = Math.max(max, array[i]);
        }
         
        int[] output = new int[n];
        CountingSort(array, output, n, max + 1);
     
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(i == 0 ? "" : " ");
            sb.append(output[i]);
        }
        System.out.println(sb.toString());
    }
     
    public static class Scanner {
        private BufferedReader br;
        private StringTokenizer tok;
 
        public Scanner(InputStream is) throws IOException {
            br = new BufferedReader(new InputStreamReader(is));
        }
 
        private void getLine() throws IOException {
            while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
        }
 
        private boolean hasNext() {
            return tok != null && tok.hasMoreTokens();
        }
 
        public String next() throws IOException {
            getLine(); return tok.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
         
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
         
        public void close() throws IOException {
            br.close();
        }
    }
 
}

Measured memory_bytes: 160052
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define show(x) cout << #x << " " << x << endl
struct edge{int from,to,cost;};
bool operator<(const edge& x,const edge& y){
	return x.cost>y.cost;
}
int par[10000],id[10000];
void init(int n){
	rep(i,n) par[i]=i;
	rep(i,n) id[i]=-1;
}
int find(int x){
	if(x==par[x]) return x;
	else return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x),y=find(y);
	if(id[x]>=0) par[y]=x;
	else par[x]=y;
}
vector<edge> es;
vector<int> costs;
int main(){
	int tt=0;
	while(true){
		tt++;
		int n,t,k;
		cin>>n>>t>>k;
		if(n==0) break;
		es.clear();
		init(n);
		rep(i,n-1){
			int a,b,c;
			cin>>a>>b>>c;
			es.pb(edge{a-1,b-1,c});
		}
		rep(i,t){
			int x;
			cin>>x;
			id[x-1]=x-1;
		}
		sort(all(es));
		costs.clear();
		rep(i,n-1){
			int a=es[i].from,b=es[i].to,c=es[i].cost;
			a=find(a),b=find(b);
			if(id[a]>=0&&id[b]>=0) costs.pb(c);
			else unite(a,b);
		}
		sort(all(costs));
//		show(costs.size());
		int sum=0;
		rep(i,k) sum+=costs[i];
		printf("Case %d: %d\n",tt,sum);
	}
}

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

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        ll n, m, v, p;
        cin >> n >> m >> v >> p;

        vector<ll> a(n);
        rep (i, n) cin >> a[i];

        sort(a.begin(), a.end(), greater<ll>());

        auto check = [&](int x) {
                if (x < p) {
                        return true;
                }

                if (a[x] + m < a[p-1]) {
                        return false;
                }

                ll s = 0;
                rep (i, n) {
                        if (i < p-1) {
                                s += m; 
                        } else if (i < x) {
                                s += a[x] + m - a[i]; 
                        } else {
                                s += m;
                        }
                }

                return s >= m * v;
        };

        int l = 0, r = n;
        while (r - l > 1) {
                int m = (l + r) / 2;
                if (check(m)) {
                        l = m;  
                } else {
                        r = m;
                }
        }

        cout << l + 1 << endl;

        return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String s=scanner.next();
        String t=scanner.next();

        int diffCount=0;
        for (int i = 0; i < s.length() && i<t.length(); i++) {
            if(s.charAt(i) == t.charAt(i))
                diffCount++;
        }

        System.out.println(diffCount);
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ii = long long;
#define all(x) x.begin(), x.end()
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(3));
    vector<vector<ii>> dp(n, vector<ii>(3));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> v[i][j];
        }
    }
    for (int j = 0; j < 3; ++j) {
        dp[0][j] = v[0][j];
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            ii r = 0;
            for (int z = 0; z < 3; ++z) {
                if (j != z) {
                    r = max(r, dp[i - 1][z]);
                }
            }
            dp[i][j] = r + v[i][j];
        }
    }
    cout << *max_element(all(dp.back())) << "\n";
}


Measured memory_bytes: 11136
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int n,a[1005];
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1, a + n + 1);
	printf("%d",a[n] - a[1]);
}


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

string tenToEight(int t) {
  string res = "";
  while(t >= 8) {
    res += (char)(t%8+'0');
    t /= 8;
  }
  res += (char)(t+'0');
  reverse(res.begin(),res.end());
  return res;
}

int main() {
  int n;
  string conv = "01235789";
  while(cin >> n && n) {
    string eight = tenToEight(n);
    for(int i = 0; i < eight.size(); ++i) cout << conv[eight[i]-'0'];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 908
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var bs = NewBufScanner(in)
	var bw = NewBufWriter(out)
	defer bw.w.Flush()

	x := bs.IntScan()
	a := bs.IntScan()
	b := bs.IntScan()

	amari := (x - a) % b
	bw.Printf("%d\n", amari)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

using namespace std;

vector <int> used[5];
vector <int> used1[5];
vector <pair <int, int> > v1, v2;
int cnt[360001];
int n, d1, d2;

void dfs1 (int x, int y, int kol) {
	if (x < 0 || x >= 2 * n || y < 0 || y >= 2 * n) return;
	if (cnt[x * (2 * n) + y]) return;    
	cnt[x * (2 * n) + y] = 1;
//	cout << x << ' ' << y << ' ' << kol << endl;
	used[kol].push_back (x * (2 * n) + y);
	for (int i = 0;i < v1.size ();i ++) {
		dfs1 (x + v1[i].first, y + v1[i].second, kol ^ 1);
		dfs1 (x - v1[i].first, y + v1[i].second, kol ^ 1);
		dfs1 (x + v1[i].first, y - v1[i].second, kol ^ 1);
		dfs1 (x - v1[i].first, y - v1[i].second, kol ^ 1);
	}
}

void dfs2 (int x, int y, int kol) {
	if (x < 0 || x >= 2 * n || y < 0 || y >= 2 * n) return;
	if (cnt[x * (2 * n) + y]) return;   
	cnt[x * (2 * n) + y] = 1;
	used1[kol].push_back (x * (2 * n) + y);
	for (int i = 0;i < v2.size ();i ++) {
		dfs2 (x + v2[i].first, y + v2[i].second, kol ^ 1);
		dfs2 (x - v2[i].first, y + v2[i].second, kol ^ 1);
		dfs2 (x + v2[i].first, y - v2[i].second, kol ^ 1);
		dfs2 (x - v2[i].first, y - v2[i].second, kol ^ 1);
	}    
}

int main () {
	cin >> n >> d1 >> d2;
	for (int i = 0;i <= d1;i ++) {
		int x = (d1 - i * i);
		if (x < 0) continue;
		int qwe = sqrt (x);
		if (qwe * qwe == x) {
			v1.push_back (make_pair (i, qwe));
		}
	}
	for (int i = 0;i <= d2;i ++) {
		int x = (d2 - i * i);
		if (x < 0) continue;
		int qwe = sqrt (x);
		if (qwe * qwe == x) {
			v2.push_back (make_pair (i, qwe));
		}           
	}
	for (int i = 0;i < 2 * n;i ++) {
		for (int j = 0;j < 2 * n;j ++) {
			dfs1 (i, j, 0);
		}
	}
	memset (cnt, 0, sizeof cnt);
	for (int i = 0;i < 2 * n;i ++) {
		for (int j = 0;j < 2 * n;j ++) {
			dfs2 (i, j, 0);
		}
	}
	for (int first = 0;first <= 1;first ++) {
		for (int second = 0;second <= 1;second ++) {
			memset (cnt, 0, sizeof cnt);
			for (int i = 0;i < used[first].size ();i ++) {
				cnt[used[first][i]] ++;
			}
			vector <int> ans;
			for (int j = 0;j < used1[second].size ();j ++) {
				if (cnt[used1[second][j]]) ans.push_back (used1[second][j]);
			}
			if (ans.size () >= n * n) {
				int kol = 0;
				for (auto to : ans) {
					int x = to;
					int lvl = x / (2 * n);
					int dsa = x - (lvl * 2 * n);
					cout << lvl << ' ' << dsa << endl;
					kol ++;
					if (kol == n * n) break;
				}
				return 0;
			}
		}
	} 
	return 0;
}

Measured memory_bytes: 28780
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
template <typename T, typename U>
pair<T, U> operator+(const pair<T, U> &l, const pair<T, U> &r) {
    return {l.first + r.first, l.second + r.second};
}
int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
char s[405][405];

pii dfs(int x, int y) {
    pii ret = {0, 0};
    char t = s[x][y];
    if (t == '#') {
        ret.first++;
    } else {
        ret.second++;
    }
    // 同じマスを重複してカウントしないようにする
    s[x][y] = 0;
    for (int i = 0; i < 4; i++) {
        char u = s[x + dx[i]][y + dy[i]];
        // まだ通っていないマス＆次マスの色が異なる
        if (u > 0 && t != u) {
            ret = ret + dfs(x + dx[i], y + dy[i]);
        }
    }
    return ret;
}

signed main() {
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        cin >> s[i] + 1;
        s[i][w + 1] = 0;
    }
    int ans = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (s[i][j]) {
                pii ret = dfs(i, j);
                ans += ret.first * ret.second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
import java.util.*;

public class Main {
    private static final char CLOWD = 'c';

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int h = scn.nextInt(), w = scn.nextInt();
            int[][] area = new int[h][w];
            for(int i = 0; i < h; i++) {
                char[] line = scn.next().toCharArray();
                for(int j = 0; j < w; j++) {
                    area[i][j] = line[j] == CLOWD ? 0 : -1;
                }
            }

            for(int t = 0; t < w; t++) {
                for(int i = 0; i < h; i++) {
                    for(int j = t + 1; j < w; j++) {
                        if(area[i][j] < 0 && area[i][~-j] >= 0) {
                            area[i][j] = -~area[i][~-j];
                        }
                    }
                }
            }

            for(int[] ary : area) {
                StringBuilder sb = new StringBuilder();
                for(int elm : ary) {
                    sb.append(elm + " ");
                }
                System.out.println(sb.toString().trim());
            }
        }
    }
}

Measured memory_bytes: 32392
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[]d = new int[N];

    int all = 0;    
    for(int i=0; i<N; i++){
        d[i] = sc.nextInt();
}
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
    all += d[i]*d[j];        
    }
}
	System.out.println(all);
      }
}


Measured memory_bytes: 35604
import java.util.*;
import java.io.*;
public class Main {                
 
    public static void main(String[] args)throws IOException{
       Scanner in = new Scanner(System.in);
       int a = in.nextInt();
       int b = in.nextInt();
       int h = in.nextInt();
       System.out.println((a+b)*h/2);
    }
}

Measured memory_bytes: 9428
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


 
 
int main(){
	int k,s;
	int cnt=0;
	cin>>k>>s;
	rep(x,k+1)rep(y,k+1){
		if(s-x-y<=k&&s-x-y>=0)++cnt;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
S = input()
part1, part2 = S[:2], S[2:]
if 1 <= int(part1) <= 12:
    if 1 <= int(part2) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(part2) <= 12:
        print('YYMM')
    else:
        print('NA')

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

constexpr int N = 21, M = 1000000000 + 7;

inline void add(int& a, int b) {
  a += b;
  if(a >= M) a -= M;
}

int n, a[N][N], dp[1 << N][N];

int go(int msk, int j) {
  if(j < 0) return 1;
  if(dp[msk][j] != -1) return dp[msk][j];
  int& ans = dp[msk][j] = 0;
  
  for(int i = 0; i < n; ++i) {
    if((1 << i) & msk && a[i][j]) {
      add(ans, go(msk ^ (1 << i), j - 1));
    }
  }
  return ans;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    fill((int*) dp, (int*) dp + (1 << N) * N, -1);
    cin >> n;
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        cin >> a[i][j];
      }
    }
    cout << go((1 << n) - 1, n - 1) << '\n';
}


Measured memory_bytes: 172288
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
	long long int n;
  	cin>>n;
  	long long int pw=1;
  	long long int a=1000000000+7;
  	for(long long int i=1;i<=n;i++){
    	i =i%a;
      pw *=i;
      pw =pw%a;
    }
  	
  	cout<< pw <<endl;
}


Measured memory_bytes: 3600
import java.util.*;
class Main{
    void solve(){
        int A, B, X, ans;
        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();
        X = sc.nextInt();

        if ( X % 500 != 0 ) X += 500 - X%500;
        int a = 0;
        int b = 0;

        if ( A < B ) {
            a = X/1000 + ((X%1000>0)?1:0);
        } else if ( A > 2*B ){
            b = X/500;
        } else {
            a = X/1000; X %= 1000;
            b = X/500;
        }

        System.out.println(A*a + B*b);
    }

    public static void main(String[] args){ new Main().solve(); }
}



Measured memory_bytes: 26340
<?php
  fscanf(STDIN, "%s", $s);
  fscanf(STDIN, "%s", $t);

  $s_array = str_split($s);
  $t_array = str_split($t);
  $count = 0;

  for($i = 0; $i<count($s_array); $i++){
  	if($s_array[$i] === $t_array[$i]){
    	
    }else{
    	$count += 1;
    }
  }

echo $count;

Measured memory_bytes: 41092
#include<iostream>
#include<string>
#include<vector>

using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[N],max = 0;
    for(int i = 0; i < N;i++){
        cin >> a[i];
    }
    int now = N-1;
    while(now > 0){
        int count = 0;
        while((a[now] <= a[now-1]) && now > 0){
          now--;
          count++;
        }
        if(max < count) max = count;
        now--;
    }
    cout << max << endl;
    return 0;
}

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

struct Edge{
  int to,id;
};

vector<Edge> g[100010];
int ans[100010];

void dfs(int v, int c=-1, int p=-1){
  int k=1;
  rep(i,g[v].size()){
    int u=g[v][i].to, ei=g[v][i].id;
    if(u==p)continue;
    if(k==c)k++;
    ans[ei]=k; k++;
    dfs(u,ans[ei],v);
  }
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }
  dfs(0);
  int K=0;
  rep(i,n-1)
    K=max(K,ans[i]);
  cout<<K<<endl;
  rep(i,n-1)
    cout<<ans[i]<<endl;
}

Measured memory_bytes: 12372
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


string make_lower(string s){
    string ret = "";
    for (int i = 0; i < s.size(); i++){
        char c = s[i];
        if ('A' <= c && c <= 'Z'){
            ret += c - 'A' + 'a';
        }else{
            ret += c;
        }
    }
    return ret;
}
int main() {
    string s;
    string W;
    cin >> W;
    int counter = 0;
    while (1){
        cin >> s;
        if (s == "END_OF_TEXT") break;
        if (make_lower(s) == W){
            counter++;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 3204
def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

h,w=map(int,input().split())
DP=[list(map(int,input().split())) for i in range(10)]

table=warshall_floyd(DP)

cnt=[]
ans=0

for i in range(h):
  cnt+=list(map(int,input().split()))


for i in cnt:
  if i==-1:
    continue
  ans+=table[i][1]


print(ans)

Measured memory_bytes: 74872
#include <stdio.h>
#define N 100000
 
int A1[N];
char A2[N];
int input1[N];
char input2[N];
 
void swap1(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
 
void swap2(char* a, char* b){
  char tmp = *a;
  *a = *b;
  *b = tmp;
}
 
int partition(int p, int r){
  int x = A1[r];
  int i = p - 1, j;
  for(j=p;j<r;j++){
    if(A1[j] <= x){
      i++;
      swap1(&A1[i], &A1[j]);
      swap2(&A2[i], &A2[j]);
    }
  }
  swap1(&A1[i+1], &A1[r]);
  swap2(&A2[i+1], &A2[r]);
  return i+1;
}
 
void quic_sort(int p, int r){
  if(p < r){
    int q = partition(p, r);
    quic_sort(p, q-1);
    quic_sort(q+1, r);
  }
}
 
int check(int n){
  int i, j;
  for(i=1;i<n;i++){
    if(A1[i-1] == A1[i]){
      int a, b;
      for(j=0;j<n;j++){
        if(A1[i-1] == input1[j] && A2[i-1] == input2[j]) a = j;
        if(A1[i] == input1[j] && A2[i] == input2[j]) b = j;
      }
      if(a > b) return 0;
    }
  }
  return 1;
}
 
main(){
  int n, i;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    getchar();
    scanf("%c%d", &A2[i], &A1[i]);
  }
  for(i=0;i<n;i++){
    input1[i] = A1[i];
    input2[i] = A2[i];
  }
  quic_sort(0, n-1);
  printf("%s\n", (check(n) ? "Stable" : "Not stable"));
  for(i=0;i<n;i++) printf("%c %d\n", A2[i], A1[i]);
  return 0;
}


Measured memory_bytes: 2720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
   String[] original =  br.readLine().split("");//????????°????????????
   String[] serch =  br.readLine().split("");//??¢????????????
 
   int flag = 0;
   for(int i = 0; i < original.length; i++){//??¢?????????????????????????????\????????§?????????
      if(serch[0].equals(original[i])){
         //int j ;
         int k = i;
         int count = 0;
         for(int j = 0;j<serch.length;j++,k++){

             if(k == original.length){
                 k = 0;//????????°????????§???????????????
             }//if
  
             if( serch[j].equals( original[k]) ){
                 count++;//???????????????????????????????????????
             }//if
 
        }//for
 
         if(count == serch.length){
            flag = 1;//????????????????????¢???????????????????????°??¨????????????????????°?????????
         }
      }//if
   }//for
 
   if(flag == 1){
 
       System.out.println("Yes");
 
   }else{
       System.out.println("No");
   }
 
  }
}

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

int main(){
  int n;
  cin >>n;
  int i = n/111;
  if(n%111 != 0) i++;
  cout << i*111 << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(dead_code)]
pub const M: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n]
    }

    let mut dp = vec_md![0i64;n+1;k+1];
    dp[0][k] = 1;
    for i in 0..n {
        let mut s = vec![0i64;k+2];
        for j in 0..k+1 {
            s[j+1] = s[j] + dp[i][j];
            s[j+1] %= M;
        }
        for j in 0..k+1 {
            // dp[i][j] + dp[i][j+1] + ... + d[i][min(j+a[i], k)]
            dp[i+1][j] = s[std::cmp::min(j+a[i], k)+1] - s[j];
            if dp[i+1][j] < 0 {
                dp[i+1][j] += M;
            }
        }
    }
    println!("{}", dp[n][0]);
}


Measured memory_bytes: 108796
#include<stdio.h>
int a[500000], n, i;
int count = 0;

void  merge(int ar[], int left, int mid, int right)
{
	int n1, n2, L[500000], R[500000], i, j, k;
	n1 = mid - left;
	n2 = right - mid;

	for (i = 0; i < n1; i++)
		L[i] = ar[left + i];

	for (i = 0; i < n2; i++)
		R[i] = ar[mid + i];

	L[n1] = 1000000001;
	R[n2] = 1000000001;
	i = j = 0;

	for (k = left; k < right; k++)
	{
		if (L[i] <= R[j])
		{
			ar[k] = L[i];
			i++;
			count++;
		}
		else
		{
			ar[k] = R[j];
			j++;
			count++;
		}

	}
}

void mergesort(int ar[], int left, int right)
{
	int mid;
	if (left + 1 < right)
	{
		mid = (left + right) / 2;
		mergesort(ar, left, mid);
		mergesort(ar, mid, right);
		merge(ar, left, mid, right);
	}
}

int main()
{

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

	mergesort(a, 0, n);

	for (i = 0; i < n; i++)
	{
		if (i != 0)
			putchar(' ');
		printf("%d", a[i]);
	}

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

	return 0;
}


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


int main(){
  string S;
  cin >> S;
  int num_A = 0;
  for(auto& s : S){
    if(s=='A') num_A++;
  }
  cout << (num_A==0||num_A==3?"No":"Yes") << endl;
  return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n;cin >> n;
  int ans=0,itr=1;
  rep(i,n){
    int a;cin >> a;
    if(itr!=a){
      ans++;
    }
    else itr++;
  }
  if(ans==n)ans=-1;
  cout << ans << endl;


}


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

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

    map<int64_t, ulong> data;
    map<int64_t, ulong> calc;
    vector<int64_t> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
        data[vec.at(i)] ++;
    }

    for(int i = 0; i < n; i++){
        calc[vec.at(i)] = data.at(vec.at(i)) * (data.at(vec.at(i)) - 1) / 2;
    }

    ulong all;
    for (auto p : calc){
        all += p.second;
    }

    for (int i = 0; i < n; i++){
        ulong count = all;

        count -= calc.at(vec.at(i));
        
        int64_t dd = data.at(vec.at(i)) - 1;
        count += dd * (dd - 1) / 2;

        cout << count << endl;
    }

}


Measured memory_bytes: 18944
#include <stdio.h>

main ()
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if (a+b>24)
	{
		a=a+b-24;
		printf("%d",a);
	}
	else if ((a+b)%24==0) 
	{ a=0;printf("%d",a);}
	else {printf("%d",a+b);}
	return 0;
} 

Measured memory_bytes: 128
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
def pow_k(x, n):

    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x
def main():  #startline-------------------------------------------
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    c.sort()
    ans = 0
    for i in range(n):
        a_left = bisect.bisect_left(a, b[i])
        c_right = bisect.bisect_right(c, b[i])
        ans += (a_left*(n-c_right))
    print(ans)
        
        
    
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 41936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n, k;
    cin>>n>>k;
    if(n*500>=k)cout<<"Yes";
    else cout<<"No";
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
package main

import "fmt"

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func bubbleSort(A []int, N int) int {
	cnt := 0
	sortRequired := true
	for sortRequired {
		sortRequired = false
		for j := N - 1; j > 0; j-- {
			if A[j] < A[j-1] {
				A[j], A[j-1] = A[j-1], A[j]
				sortRequired = true
				cnt++
			}
		}
	}
	return cnt
}

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)
	cnt := bubbleSort(nums, N)
	fmt.Print(nums[0])
	for i := 1; i < N; i++ {
		fmt.Print(" ")
		fmt.Print(nums[i])
	}
	fmt.Print("\n")
	fmt.Println(cnt)
}



Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9, mod = 1e9+7;
#define endl     '\n'


void solve(){
    ll n, d;
    cin >> n >> d;
    ll p, q, c = 0;
    while (n--){
        cin >> p >> q;
        if(p*p + q*q <= d*d) c++;
    }
    cout << c << "\n";

}


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

    solve();
    return 0;
}


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

int main(){
    int n,cnt = 0;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++) cin >> d.at(i);
    sort(d.begin(),d.end());
    for(int i = d[n/2-1];i < d[n/2];i++){
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=500005;
struct ab{int f,t;} t[N];
int h,hh[N],vv[N],ans[N];
void make(int x,int y)
{
	t[++h].f=hh[x];
	t[h].t=y;
	hh[x]=h;
}
int dfs1(int x,int y,int z)
{
	if(x>z) return 0;
	int now=1;
	for(int i=hh[x];i;i=t[i].f)
	{
		int j=t[i].t;
		if(j==y) continue;
		now+=dfs1(j,x,z);
	}
	return now;
}
int dfs2(int x,int y,int z)
{
	int now=1;
	for(int i=hh[x];i;i=t[i].f)
	{
		int j=t[i].t;
		if(j==y) continue;
		if(j<z) now+=dfs2(j,x,z);
	}
	return now;
}
void dfs(int x,int y,int z,int v)
{
	if(x>z) v+=dfs2(x,y,z);
	ans[x]=v;
	for(int i=hh[x];i;i=t[i].f)
	{
		int j=t[i].t;
		if(j==y) continue;
		if(x>z) dfs(j,x,x,v+dfs1(j,x,x)-dfs1(j,x,z));
		else dfs(j,x,z,v);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		make(x,y),make(y,x);
	}
	dfs(1,0,0,0);
	for(int i=2;i<=n;i++) printf("%d ",ans[i]-1);printf("\n");
	return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 50;

void solve() {
	char c;
	cin >> c;
	cout << (char) (c + 1);
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    if (t)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}      

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
int a[103];
int main(){
  int n,m,jsd=0;
  cin>>n>>m;
  for (int i=0;i<n;i++){
  	cin>>a[i];
  	jsd += a[i];
  }
  sort (a,a+n);
  cout<<n + (m - jsd)/a[0];
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

using namespace std;

const double inf=1e9;

struct D {
  vector<double> low, high;
  D(): low(3, inf), high(3, -inf) {}

  void add(double x, int v) {
    ++v;
    mins(low[v], x);
    maxs(high[v], x);
  }

  double length(double t) {
    double min_low = inf, max_high = -inf;
    rep(i, 3) {
      mins(min_low,  low[i] + i * t);
      maxs(max_high, high[i] + i * t);
    }
    return max_high - min_low;
  }

  vector<double> events() {
    vector<double> ts;
    rep(i, 3)rep(j,i) {
      {
        double t = (low[j] - low[i]) / (i - j);
        if (t > 0) ts.push_back(t);
      }

      {
        double t = (high[j] - high[i]) / (i - j);
        if (t > 0) ts.push_back(t);
      }
    }
    return ts;
  }
};

int main() {
  int n;
  cin >> n;
  D xd, yd;
  rep(i, n) {
    int x, y;
    char d;
    cin >> x >> y >> d;
    switch (d) {
      case 'L': xd.add(x, -1), yd.add(y, 0); break;
      case 'R': xd.add(x, 1), yd.add(y, 0); break;
      case 'U': xd.add(x, 0), yd.add(y, 1); break;
      case 'D': xd.add(x, 0), yd.add(y, -1); break;
    }
  }
  vector<double> ts;
  ts.push_back(0);
  ts.push_back(inf);
  {
    auto nts = xd.events();
    ts.insert(ts.end(), nts.begin(), nts.end());
  }
  {
    auto nts = yd.events();
    ts.insert(ts.end(), nts.begin(), nts.end());
  }

  sort(ts.begin(), ts.end());
  double ans = 1e17;
  for (double t: ts) {
    double now = xd.length(t) * yd.length(t);
    mins(ans, now);
  }
  printf("%.10f\n", ans);
  return 0;

}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			int[] prog, freq;
			prog = new int[n];
			freq = new int[n];

			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line);

			for (int i = 0; i < n; i++) {
				prog[i] = Integer.parseInt(st.nextToken());
			}

			// 出現頻度操作
			int op = 0;
			while (true) {

				// 数え上げ
				boolean[] chk = new boolean[n];
				for (int i = 0; i < n; i++) {
					if (!chk[i]) {
						int f = 0, t = 0;
						int[] idx = new int[n];
						for (int j = 0; j < n; j++) {
							if (!chk[j] && prog[i] == prog[j]) {
								chk[j] = true;
								f++;
								idx[t] = j;
								t++;
							}
						}
						for (int j = 0; j < t; j++) {
							freq[idx[j]] = f;
						}
					}
				}
				//
				if (!Arrays.equals(prog, freq)) {
					prog = Arrays.copyOf(freq, n);
					op++;
				} else {
					break;
				}
			}
			System.out.println(op);
			if (n > 1) {
				System.out.print(freq[0]);
				for (int i = 1; i < n - 1; i++) {
					System.out.print(" " + freq[i]);
				}
				System.out.println(" " + freq[n - 1]);
			} else {
				System.out.println(freq[0]);
			}
		}
	}
}

Measured memory_bytes: 20936