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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_N = 1300000;
bool flag[MAX_N+1];
int prime[MAX_N+1];
int N;

int getPrime(int MAX_N = MAX_N, bool* flag = flag, int* prime = prime)
{
  int ptr = 0;
  prime[ptr++] = 2;
  flag[1] = true;
  for(int i=4; i<=MAX_N; i+=2) flag[i] = true;
  for(int i=3; i<=MAX_N; i+=2){
    if(!flag[i]){
      prime[ptr++] = i;
      for(int j=2*i; j<=MAX_N; j+=i) flag[j] = true;
    }
  }
  return ptr;
}


int main()
{
  int ptr = getPrime();

  while(cin >> N, N){
    if(flag[N]) cout << prime[upper_bound(prime, prime + ptr, N) - prime] - prime[lower_bound(prime, prime + ptr, N) - prime - 1] << endl;
    else cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, m;
    cin >> n >> m;
    VL a(n);
    REP(i,n){
        a[i] = in();
    }
    sort(ALL(a));
    reverse(ALL(a));
    ll ok = 0, ng = 1e6;
    while (ng - ok > 1){
        ll x = (ok + ng) / 2;
        ll s = 0;
        int j = n - 1;
        REP(i,n){
            while (j >= 0 && a[i] + a[j] < x) j--;
            s += j + 1;
        }
        if (s >= m) ok = x;
        else ng = x;
    }
    VL s(n + 1);
    REP(i,n) s[i + 1] = s[i] + a[i];
    ll c = 0, ans = 0;
    int j = n - 1;
    REP(i,n){
        while (j >= 0 && a[i] + a[j] < ok) j--;
        ans += (j + 1) * a[i] + s[j + 1];
        c += j + 1;
    }
    ans -= (c - m) * ok;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(5) == '0' && (S.at(6) == '1' || S.at(6) == '2' || S.at(6) == '3' || S.at(6) == '4')) 
cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>

using namespace std;
using ll = long long int;
using pll = pair<ll, ll>;


int main(){
    ll N, K;
    cin >> N >> K;

    ll const MAX = (N - 1) * (N - 2) / 2;
    // 感想戦
    if(K > MAX){
        cout << -1 << endl;
        return 0;
    }

    vector<pll> edge;
    for(ll i = 2; i <= N; ++i){
        edge.emplace_back(1, i);
    }
    ll diff = MAX - K;
    for(ll i = 1; i < N - 2; ++i){
        if(!diff) break;
        for(ll j = 2; j <= N; ++j){
            if(!diff) break;
            edge.emplace_back(j, (j + i) > N ? j + i - N + 1 : j + i);
            diff--;
        }
    }
    cout << edge.size() << endl;
    for(auto &v : edge){
        cout << v.first << " " << v.second << endl;
    }

    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int[] first = toIntArray(stdin.readLine());
        int n = first[0];
        int m = first[1];
        int l = first[2];

        int inf = Integer.MAX_VALUE / 2 - 1;
        int[][] wf1 = new int[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(wf1[i], inf);
            wf1[i][i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int[] line = toIntArray(stdin.readLine());
            int a = line[0] - 1;
            int b = line[1] - 1;
            int c = line[2];
            wf1[a][b] = wf1[b][a] = c;
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    wf1[i][j] = Math.min(wf1[i][j], wf1[i][k] + wf1[k][j]);
                }
            }
        }

        int[][] wf2 = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                wf2[i][j] = wf1[i][j] <= l ? 1 : inf;
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    wf2[i][j] = Math.min(wf2[i][j], wf2[i][k] + wf2[k][j]);
                }
            }
        }

        int q = Integer.parseInt(stdin.readLine());
        for (int i = 0; i < q; i++) {
            int[] line = toIntArray(stdin.readLine());
            int s = line[0] - 1;
            int t = line[1] - 1;
            if (wf2[s][t] == inf) {
                stdout.println(-1);
            } else {
                stdout.println(wf2[s][t] - 1);
            }
        }
    }

    private Pattern space = Pattern.compile(" ");

    private int[] toIntArray(String line) {
        return space.splitAsStream(line).mapToInt(Integer::parseInt).toArray();
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 63500
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_7D{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var preOrder = sr.Next<int>(N);
            var inOrder = sr.Next<int>(N);

            var cnt = 0;
            var res = new List<int>();

            Action<int, int> reconstruct = null;
            reconstruct = (l, r) =>{
                if(cnt >= N || l >= r) return;
                var cp = preOrder[cnt++];
                var m = Array.IndexOf(inOrder, cp);

                reconstruct(l, m);
                reconstruct(m + 1, r);
                res.Add(cp);
            };
            reconstruct(0, N);

            Console.WriteLine(string.Join(" ", res.Select(x => x.ToString()).ToArray()));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 10464
import java.io.*;

class Main{ 
public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] div = str.split(" ");
        int x = Integer.parseInt(div[0]);
        int y = Integer.parseInt(div[1]);
            if(x < y)
                System.out.println("a < b");
            else if(x > y)
                System.out.println("a > b");
            else if(x == y)
                System.out.println("a == b");
 }
}
      

Measured memory_bytes: 17072
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;

//
int main()
{
  cin.tie(0);
ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A;
ll common;
  cin>>common;
    for (int i = 1; i < N; i++)
    {
        ll ai;
        cin >> ai;
        A.push_back(ai);
    }
  for(auto x:A)
  {
    common=__gcd(x,common);
  }
    cout << common << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Forest_Uni {
	vector<pair<UL, UL>> v;
	ULL Div = 0;
	void init(UL n) {
		v.clear();
		rep(i, n) add();
	}
	void add() {
		Div += v.size();
		v.push_back({ v.size(), 1 });
	}
	UL root(UL p) {
		if (v[p].first == p) return p;
		return v[p].first = root(v[p].first);
	}
	void unite(UL a, UL b) {
		UL A = root(a);
		UL B = root(b);
		if (A != B) {
			v[A].first = B;
			Div -= v[B].second * v[A].second;
			v[B].second += v[A].second;
		}
	}
};

struct Problem {

	void Solve(){
		UL N, M; cin >> N >> M;
		vector<pair<UL, UL>> B(M);
		rep(i, M) cin >> B[i].first >> B[i].second;
		rep(i, M) { B[i].first--; B[i].second--; }
		reverse(B.begin(), B.end());
		vector<ULL> ans;
		Forest_Uni G;
		G.init(N);
		rep(i, M) {
			ans.push_back(G.Div);
			G.unite(B[i].first, B[i].second);
		}
		reverse(ans.begin(), ans.end());
		rep(i, ans.size()) cout << ans[i] << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 3828
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int h,w;

int corner[21][21];
char tatami[20][20];

int dfs(int i,int j){
	if(i==h) return 1;
	if(j==w) return dfs(i+1,0);

	if(tatami[i][j]=='#') return dfs(i,j+1);

	int res=0;
	// 縦に置く
	if(i+1<h && tatami[i+1][j]=='.'){
		corner[ i ][ j ]++;
		corner[ i ][j+1]++;
		corner[i+2][ j ]++;
		corner[i+2][j+1]++;
		tatami[i][j]=tatami[i+1][j]='#';
		if(corner[i][j]<4 && corner[i][j+1]<4 && corner[i+2][j]<4 && corner[i+2][j+1]<4){
			res+=dfs(i,j+1);
		}
		tatami[i][j]=tatami[i+1][j]='.';
		corner[ i ][ j ]--;
		corner[ i ][j+1]--;
		corner[i+2][ j ]--;
		corner[i+2][j+1]--;
	}
	// 横に置く
	if(j+1<w && tatami[i][j+1]=='.'){
		corner[ i ][ j ]++;
		corner[ i ][j+2]++;
		corner[i+1][ j ]++;
		corner[i+1][j+2]++;
		tatami[i][j]=tatami[i][j+1]='#';
		if(corner[i][j]<4 && corner[i][j+2]<4 && corner[i+1][j]<4 && corner[i+1][j+2]<4){
			res+=dfs(i,j+1);
		}
		tatami[i][j]=tatami[i][j+1]='.';
		corner[ i ][ j ]--;
		corner[ i ][j+2]--;
		corner[i+1][ j ]--;
		corner[i+1][j+2]--;
	}
	return res;
}

int main(){
	for(;scanf("%d%d",&h,&w),h;){
		rep(i,h) rep(j,w) tatami[i][j]='.';
		printf("%d\n",dfs(0,0));
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

ll l[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	ll sum = 0ll;
	REPN(i, 1, n) {
		scanf("%lld", &l[i]);
		sum += l[i];
	}
	int ind = 0;
	ll cur = 0ll;
	for(; ind <= n; ind++) {
		cur += l[ind];
		if (2 * cur >= sum) {
			break;
		}
	}
	ll v = min(2 * cur - sum, sum - 2 * (cur - l[ind]));
	cout << v << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	int ans = t.size();
	for (int i = 0; i <= s.size() - t.size(); i++) {
		int cnt = 0;
		// printf("---\n");
		for (int j = 0; j < t.size(); j++) {
			// printf("%c %c\n", s[i+j], t[j]);
			if (s[i+j] != t[j]) {
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3200
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          if(Input.ScanInt()==1)
            Console.WriteLine("Hello World");
          else
            Console.WriteLine(Input.ScanInt()+Input.ScanInt());
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(){
	int a;
	int b;
	int x;
	int y;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)break;
		for(x=0;x<a;x++){
			for(y=0;y<b;y++){
				if((x+y)%2==0){
				printf("#");
			}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoder.Program;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC132().SolveB(new ConsoleInput(Console.In, ' '));
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
  class ABC132
  {
    public void SolveB(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var P = cin.ReadIntArray(n);
            int count = 0;
            for(int i = 1; i < n - 1; i++)
            {
                if (Max(P[i - 1], P[i + 1]) > P[i] && Min(P[i - 1], P[i + 1]) < P[i]) count++;
            }
            WriteLine(count);
            ReadLine();
        }
  }
}

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
const ll mod = 1000000007;
typedef pair<int, int> P;

struct circle {
	P p;int r;
	bool operator<(const circle &c)const {
		if (r != c.r)return r < c.r;
		return p < c.p;
	}
};
int n;

int dist_2(P a, P b) {
	int dx = a.first - b.first;
	int dy = a.second - b.second;
	return dx * dx + dy * dy;
}

bool cc(circle a, circle b) {
	int dd = dist_2(a.p, b.p);
	int lr = b.r - a.r; lr = lr * lr;
	int rr = b.r + a.r; rr = rr * rr;
	return lr <= dd && dd <= rr;
}

void solve() {
	P s, g;
	cin >> s.first >> s.second >> g.first >> g.second;
	vector<circle> le,ri;
	rep(i, n) {
		int x, y, r; cin >> x >> y >> r;
		P p = { x,y };
		int rr = r * r;
		int dl = dist_2(p, s),dr=dist_2(p,g);
		if (dl < rr&&dr < rr)continue;
		if (dl < rr) {
			le.push_back({ p,r });
		}
		if (dr < rr) {
			ri.push_back({ p,r });
		}
	}
	sort(le.begin(), le.end());
	sort(ri.begin(), ri.end());
	vector<int> cle(le.size(), 1);
	vector<int> cri(ri.size(), 1);
	rep(i, le.size()) {
		Rep(j, i + 1, le.size()) {
			if (!cc(le[i], le[j])) {
				cle[j] = max(cle[j], cle[i] + 1);
			}
		}
	}
	rep(i, ri.size()) {
		Rep(j, i + 1, ri.size()) {
			if (!cc(ri[i], ri[j])) {
				cri[j] = max(cri[j], cri[i] + 1);
			}
		}
	}
	int ans = 0;
	rep(i, le.size())ans = max(ans, cle[i]);
	rep(i, ri.size())ans = max(ans, cri[i]);
	rep(i, le.size()) {
		rep(j, ri.size()) {
			if (!cc(le[i], ri[j])) {
				ans = max(ans, cle[i] + cri[j]);
			}
		}
	}
	cout << ans << endl;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> n, n) {
		solve();
	}
        //stop
	return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) cin >> D[i];
    int M;
    cin >> M;
    vector<int> T(M);
    rep(i, M) cin >> T[i];
    sort(ALL(D));
    sort(ALL(T));
    int idx = 0;
    rep(i, M) {
        bool flag = true;
        FOR(j, idx, N) if (T[i] == D[j]) {flag = false; idx = j + 1; break;}
        if (flag) {cout << "NO" << endl; return 0;}
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4788
from collections import deque

n = int(input())
matches = []
for _ in range(n):
    matches.append(list(map(lambda x: int(x)-1, input().split())))

q = deque(range(n))

days = [0]*n  # 各選手の現在の日付

while q:
    x = q.popleft()  # 試合する人
    if len(matches[x]) == 0:  # 試合が全て終わってる?
        continue
    y = matches[x][0]  # xの次の対戦相手
    if matches[y][0] == x:
        day = max(days[x], days[y])+1
        days[x] = day
        days[y] = day
        q.append(x)
        q.append(y)
        _ = matches[x].pop(0)
        _ = matches[y].pop(0)

if not any(matches):  # 全ての試合をしょうか
    print(max(days))
else:
    print(-1)


Measured memory_bytes: 35316
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;


int main()
{
  ll X; cin >> X;
  ll a = X / 11;
  ll b = X % 11;
  if (b == 0) cout << 2 * a << endl;
  else if (b <= 6) cout << 2 * a + 1 << endl;
  else cout << 2 * a + 2 << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s, t string
  fmt.Scanf("%s", &s)
  fmt.Scanf("%s", &t)
  
  ans := "Yes"
  if s != t[:len(s)]{
    ans = "No"
  }
  if len(s)+1 != len(t) {
    ans = "No"
  }
  
  fmt.Printf("%s\n", ans)
}

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

int main() {
 	unsigned int N;
  	cin >> N;
  
  	int64_t a = 2;
  	int64_t b = 1;
  	int64_t c = a + b;
  
  if(N == 1) {
   	cout << b;
  }
  
  else if(2 <= N) {
  		for(int i=0; i<N - 2; i++) {
    	  	a = b;
     		b = c;
     	 	c = a + b;
    	}
    
    	cout << c;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pie 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

void solve()
{
	string a;
	cin>>a;
	lli n=a.size();
	cout<<a;
	if(a[n-1]=='s')cout<<"es";
	else cout<<"s";
}
int main()
{
/////////////////////////////////////
    fastio;
  
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner vd = new Scanner(System.in);
		int n = vd.nextInt();
		int a = vd.nextInt();
		int b = vd.nextInt();
		if(n*a<b) System.out.println(a*n);
		else System.out.println(b);
		
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

using namespace std;

int main(void){
  int N;
  cin >> N;
  cout << N*N*N << endl;
}
  

Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        int n = int.Parse(Console.ReadLine());
        var ans = string.Empty;
        for (int i = 0; i < s.Length; i++)
        {
            if (i % n == 0) ans += s[i];
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
s = int(input())
numSeq = [s]
cnt = 1
while True:
        if s%2 == 0 :
                s = int(s/2)
        else :
                s = 3*s + 1
        if s in numSeq:
                break
        numSeq.append(s)
        cnt += 1
print(cnt+1)

Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()
	okline := 0
	alist := make([]int, n)
	for i := 0; i < n; i++ {
		alist[i] = nextInt()
		okline += alist[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(alist)))

	if alist[m-1]*(4*m) >= okline {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1756
#include<stdio.h>

#define MAX 101
static const int INF = (1<<21);

int n,youso;

int U[MAX];
int key1[MAX],key2[MAX],G[MAX][MAX];

void MinimumSpanningTree(void){
  int i,j;
  int min;
  for(i = 0;i < n;i++){
    key2[i] = INF;
    key1[i] = -1;
  }
  key2[0] = 0;
  
  for(i = 0;i < n;i++){
    U[i] = -1;
  }
  
  while(1){
    youso = -1;
    min = INF;
    for(i = 0;i < n;i++){
      if(key2[i] < min && U[i] == -1){
	youso = i;
	min = key2[i];
      }
    }
    
    if(youso == -1){
      break;
    }
    U[youso] = 1;
    for(j = 0;j < n;j++){
      if(G[youso][j] < key2[j] && U[j] == -1){
	key2[j] = G[youso][j];
	key1[j] = youso;
      }
    }
  }
}

int main(){
  int i,j;
  int sum = 0;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      scanf("%d",&youso);
      G[i][j] = (youso == -1)?INF:youso;
    }
  }

  MinimumSpanningTree();

  for(i = 0;i < n;i++){
    if(key1[i] != -1){
      sum+=G[i][key1[i]];
    }
  }
  
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
ld pi = acos(-1);
 
int main()
{
 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
    ld n;
    cin >> n;
    cout << fixed << setprecision(9) << (ld)2*n*pi << '\n';
 

 
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3176
from collections import deque

def main():
    h, w = map(int, input().split())
    G = [list(input()) for i in range(h)]
    dy, dx = [-1, 1, 0, 0], [0, 0, -1, 1]
    
    dist = [[-1 for j in range(w)] for i in range(h)]
    que = deque()
    px = [[-1 for j in range(w)] for i in range(h)]
    py = [[-1 for j in range(w)] for i in range(h)]
    dist[0][0] = 0
    que.append((0, 0))
    while (len(que) != 0):
        y, x = que[0][0], que[0][1]
        que.popleft()

        for i in range(4):
            ny, nx = y+dy[i], x+dx[i]
            if (ny < 0) or (h <= ny) or (nx < 0) or (w <= nx):
                continue
            if G[ny][nx] == "#":
                continue
            if dist[ny][nx] == -1:
                dist[ny][nx] = dist[y][x] + 1
                py[ny][nx], px[ny][nx] = y, x
                que.append((ny, nx))

    if dist[h-1][w-1] == -1:
        print(dist[h-1][w-1])
    else:
        y, x = h - 1, w - 1
        while y != -1 and x != -1:
            G[y][x] = "o"
            y, x = py[y][x], px[y][x]
        ans = 0
        for i in G:
            for j in i:
                if j == ".":
                    ans += 1
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3436
from collections import Counter

N = int(input())
alist = list(map(int, input().split()))
alist = [0] + alist
sumlist = []
# (j, wj)のリストを作る
for i in range(1,N+1):
    sumlist.append(i+alist[i])
sumlist.sort()
sum_cnt = Counter(sumlist)
ans = 0
# 差と一致するものを探す
for i in range(1, N+1):
    diff = i - alist[i]
    if diff in sum_cnt:
        ans += sum_cnt[diff]
print(ans)

Measured memory_bytes: 42792
n=int(input())
def Euclid(a,b):
    if a<b:
        return Euclid(b,a)
    if a%b==0:
        return b
    return Euclid(b,a%b)

def lcm(a,b):
    return a*b//Euclid(a,b)
ans=int(input())
for i in range(n-1):
    x=int(input())
    ans=lcm(ans,x)
print(ans)

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

using namespace std;

vector<int> colors;
unordered_map<int, vector<pair<int, int>>> edges;

void dfs(int idx, int prev, int color) {
	colors[idx] = color;
	for(int i = 0; i < edges[idx].size(); i++)
	{
		int next = edges[idx][i].first;
		if(next == prev) continue;
		int dist = edges[idx][i].second;
		if(dist % 2 == 0)
		{
			dfs(next, idx, color);
		}
		else
		{
			dfs(next, idx, color ^ 1);
		}
	}
}

int main()
{
	int N;
	cin >> N;
	int x, y, z;
	for(int i = 0; i < N - 1; i++)
	{
		cin >> x >> y >> z;
		edges[x].emplace_back(make_pair(y, z));
		edges[y].emplace_back(make_pair(x, z));

	}
	colors = vector<int>(N + 1);
	dfs(1, -1, 0);
	for(int i = 1; i <= N; i++)
	{
		cout << colors[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 12964
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

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

    vector<int> b(n);
    int now = 1;
    rep(i, n) {
        if (a[i] == now) now++;
        b[i] = now;
        if (now == 1) now++;
    }

    ll ans = 0;

    rep(i, n) {
        ans += (a[i] - 1) / b[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3964
def solve(M, K):
    if K == 0:
        r = [i for i in range(0, 2 ** M)]
        return " ".join(str(c) for c in r + r[::-1])
    elif M > 1 and K < (2 ** M):
        r = [i for i in range(0, (2 ** M)) if i != K]
        return " ".join(str(c) for c in r[::-1] + [K] + r + [K])
    else:
        return "-1"
 
 
if __name__ == "__main__":
    M, K = tuple(map(int, input().split(" ")))
    print(solve(M, K))

Measured memory_bytes: 28564
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

long MOD = 10L^^9 + 7;
void main() {
    int N = readln.chomp.to!int;
    long[] aryT = readln.split.to!(long[]);
    long[] aryA = readln.split.to!(long[]);
    if (aryT.back != aryA.front) {
        writeln(0);
    } else {
        long[] maxH = N.iota.map!(i => min(aryT[i], aryA[i])).array;
        long[] minH = N.rep!(() => 1L);
        foreach(i; 0..N) {
            if (i==0 || aryT[i]>aryT[i-1]) minH[i] = aryT[i];
            auto j = N-i-1;
            if (i==0 || aryA[j]>aryA[j+1]) minH[j] = aryA[j];
        }
        long[] po = N.iota.map!(i => maxH[i]-minH[i]+1).array;
        if (po.canFind!(a => a<=0)) {
            writeln(0);
        } else {
            1L.reduce!((a, b) => a*b%MOD)(po).writeln;
        }
    }
}


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

int main(void)
{
    int n;
    int s[1001];
    int sum;//合計
    double m;//平均値
    double a;//標準偏差
    double a2;//分散
    double z;  


    while(1){

        sum = 0;
        m = 0.0;
        a = 0.0;
        a2 = 0.0;
        z = 0.0;        

        scanf("%d", &n);
        if(n == 0){
            break;
        }

        for(int i = 0; i < n; i++){
            scanf("%d", &s[i]);
            sum += s[i]; 
        }
        m = (double)sum / (double)n;
        for(int j = 0; j < n; j++){
            z += (s[j] - m) * (s[j] - m);
        }
        a2 = z / n;
        a = sqrt(a2);
        printf("%lf\n", a);
    }
    return (0);
}



Measured memory_bytes: 2100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * Property Distribution
 */
public class Main {

	static char DISTRIBUTED = '\0';
	static Queue<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

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

			int h = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int w = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			// read in.
			char[][] prop = new char[h + 2][w + 2];
			for (int i = 1; i < h + 1; ++i) {
				line = br.readLine();
				for (int j = 1; j < w + 1; ++j) {
					prop[i][j] = line.charAt(j - 1);
				}
			}

			// solve
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();
			count = 0;
			for (int i = 1; i < h + 1; ++i) {
				for (int j = 1; j < w + 1; ++j) {
					if (prop[i][j] != DISTRIBUTED) {
						char fruit = prop[i][j];
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							distribute(prop, fruit);
						}
						++count;
					}
				}
			}

			// print
			System.out.println(count);
		}
	}

	static void distribute(char[][] prop, char fruit) {

		final int V[] = { 1, -1, 0, 0 };
		final int H[] = { 0, 0, 1, -1 };

		int x, y;
		x = xs.remove();
		y = ys.remove();

		if (prop[x][y] == fruit) {

			prop[x][y] = DISTRIBUTED;

			for (int i = 0; i < 4; ++i) {
				int xv, yh;
				xv = x + V[i];
				yh = y + H[i];
				if (prop[xv][yh] == fruit) {
					xs.add(xv);
					ys.add(yh);
				}
			}
		}
	}
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

struct func{
  int l,r,v;
};

main(){
  int n; cin >> n;
  vector<struct func> f(n+2);
  int t = 0; // T
  vi a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n){
    f[i].l = t;
    t += 2 * a[i]; // 0.5刻みで見るため2倍
    f[i].r = t;
    f[i].v = b[i];
  }
  // 最初の速度と最後の速度
  f[n].l = f[n].r = f[n].v = f[n+1].v = 0;
  f[n+1].l = f[n+1].r = t;
  //rep(i,n+2) cout << f[i].l << " " << f[i].r << " " << f[i].v << endl;

  double before = 0, now; // v(a), v(a + 0.5)
  double ans = 0;
  FOR(i,1,t+1){ // i : a
    now = inf;
    // v(a + 0.5)を求める
    rep(j,n+2){
      if(i < f[j].l){
	now = min(now, f[j].v + double(f[j].l - i) / 2); // 割る2は2倍した分
      }else if(f[j].r < i){
	now = min(now, f[j].v + double(i - f[j].r) / 2);
      }else{
	now = min(now, (double)f[j].v);
      }
    }
    //cout << double(i)/2 << "\t" << before << "\t" << now << endl;
    ans += (before + now) / 4;
    before = now;
  }
  printf("%.10f\n",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] inputs = scanner.nextLine().split("");
		int[] nums = new int[4];
		for (int i = 0; i < 4; i++) {
			nums[i] = Integer.parseInt(inputs[i]);
		}

		int[] masks = {4, 2, 1};

		for (int opes = 0; opes < 8; opes++) {
			int result = nums[0];
			for (int opeIndex = 0; opeIndex < 3; opeIndex++) {
				if ((opes & masks[opeIndex]) > 0) {
					result += nums[opeIndex + 1];
				} else {
					result -= nums[opeIndex + 1];
				}
			}
			if (result == 7) {
				String[] operators = String.format("%3s", Integer.toBinaryString(opes)).replaceAll("[ 0]", "-").replaceAll("1", "+").split("");
				StringBuilder expression = new StringBuilder();
				expression.append(inputs[0]);
				for (int i = 0; i < 3; i++) {
					expression
						.append(operators[i])
						.append(inputs[i + 1]);
				}
				expression
					.append("=7");
				System.out.println(expression);
				return;
			}
		}
	}
}


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

int main(){
    int N;cin >> N;
    vector<pair<int,int>> job(N);
    rep(i,N){
        int a,b;
        cin >> a >> b;
        job[i] = make_pair(b,a);
    }
    sort(job.begin(),job.end());
    bool ok = true;
    ll sum = 0;
    for(auto e : job){
        if(!ok)break;
        sum += e.second;
        if(e.first < sum)ok = false;
    }    
    if(ok)puts("Yes");
    else puts("No");
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    for(int i = 1; i < n; i++) {
        rep(j, n-1) cout << a[j] << ' ';
        cout << a[n-1] << endl;
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
    }
    rep(j, n-1) cout << a[j] << ' ';
    cout << a[n-1] << endl;
}


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

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

struct cube{
  int c[6];
  inline int &operator [] (int i){
    return c[i-1];
  }
};

void rotate2(cube &c){
  int tmp = c[1];
  c[1] = c[5];
  c[5] = c[6];
  c[6] = c[2];
  c[2] = tmp;
}
void rotate3(cube &c){
  int tmp = c[1];
  c[1] = c[4];
  c[4] = c[6];
  c[6] = c[3];
  c[3] = tmp;
}
void rotate4(cube &c){
  int tmp = c[1];
  c[1] = c[3];
  c[3] = c[6];
  c[6] = c[4];
  c[4] = tmp;
}
void rotate5(cube &c){
  int tmp = c[1];
  c[1] = c[2];
  c[2] = c[6];
  c[6] = c[5];
  c[5] = tmp;
}
void rotate23(cube &c){
  int tmp = c[2];
  c[2] = c[4];
  c[4] = c[5];
  c[5] = c[3];
  c[3] = tmp;
}
void rotate24(cube &c){
  int tmp = c[2];
  c[2] = c[3];
  c[3] = c[5];
  c[5] = c[4];
  c[4] = tmp;
}

inline bool operator < (const cube &a, const cube &b){
  REP(i,6){
    if(a.c[i] != b.c[i]) return a.c[i] < b.c[i];
  }
  return false;
}

int main(){
  map<string,int> m;
  m["Red"]=0; m["Yellow"]=1; m["Blue"]=2;
  m["Magenta"]=3; m["Green"]=4; m["Cyan"]=5;
  int n;
  while(cin>>n, n){
    set<cube> s;
    REP(i,n){
      cube c;
      REP(j,6){
	string tmp; cin>>tmp;
	c[j+1] = m[tmp];
      }
      if(c[2] == 0){
	rotate5(c);
      }else if(c[3] == 0){
	rotate4(c);
      }else if(c[4] == 0){
	rotate3(c);
      }else if(c[5] == 0){
	rotate2(c);
      }else if(c[6] == 0){
	rotate5(c);
	rotate5(c);
      }

      if(c[6] != 1){
	if(c[3] == 1){
	  rotate24(c);
	}else if(c[4] == 1){
	  rotate23(c);
	}else if(c[5] == 1){
	  rotate24(c);
	  rotate24(c);
	}
      }else{
	if(c[3] == 2){
	  rotate24(c);
	}else if(c[4] == 2){
	  rotate23(c);
	}else if(c[5] == 2){
	  rotate24(c);
	  rotate24(c);
	}
      }
      s.insert(c);
    }
    printf("%d\n",n-s.size());
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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 main(){
    int a,b;
    cin >> a >> b;
    cout << a*b <<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    vector<ll> x(3);
    cin >> n >> x[0] >> x[1] >> x[2];
    vector<ll> l(n);
    rep(i, 0, n) cin >> l[i];
    ll ans = INF;
    rep(i, 0, pow(4, n))
    {
        ll tmp = i;
        vector<vector<ll>> v(4);
        ll cta = 0;
        rep(j, 0, n)
        {
            auto x = (i >> (2 * j)) % 4;
            v[x].push_back(l[j]);
        }
        if (v[0].empty() || v[1].empty() || v[2].empty())
            continue;
        ll sa = abs(accumulate(all(v[0]), 0) - x[0]) + (v[0].size() - 1) * 10;
        ll sb = abs(accumulate(all(v[1]), 0) - x[1]) + (v[1].size() - 1) * 10;
        ll sc = abs(accumulate(all(v[2]), 0) - x[2]) + (v[2].size() - 1) * 10;
        ans = min(ans, sa + sb + sc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N, K;
  cin >> N >> K;
  if (N%K==0) {
    cout << "0\n";
  } else {
    cout << "1\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(){
	string s;
	while(getline(cin, s)){
		set<size_t> replaced;
		size_t p = 0;
		while((p = s.find("apple", p)) != string::npos){
			replaced.insert(p);
			s[p + 0] = 'p';
			s[p + 1] = 'e';
			s[p + 2] = 'a';
			s[p + 3] = 'c';
			s[p + 4] = 'h';
		}
		p = 0;
		while((p = s.find("peach", p)) != string::npos){
			if(replaced.find(p) != replaced.end()){
				++p;
				continue;
			}
			s[p + 0] = 'a';
			s[p + 1] = 'p';
			s[p + 2] = 'p';
			s[p + 3] = 'l';
			s[p + 4] = 'e';
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextInt()) {
                int dataSet = sc.nextInt();
                for (int i = 0; i < dataSet; i++) {
                    String originalNum = sc.next();
                    char[] charNum = originalNum.toCharArray();

                    // asc
                    Arrays.sort(charNum);
                    int maxNum = Integer.parseInt(String.valueOf(charNum));

                    // desc
                    int minNam = Integer
                            .parseInt(String.valueOf(desc(charNum)));

                    // max-min
                    int result = minNam - maxNum;
                    System.out.println(result);
                }
            }
        } finally {
            sc.close();
        }
    }

    public static char[] desc(char[] c) {
        char[] after = new char[c.length];

        for (int i = 0; i < c.length; i++) {
            after[i] = c[c.length - (1 + i)];
        }
        return after;
    }
}

Measured memory_bytes: 26348
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

n = inn()
a= inl()
sum = 0.0
for i in range(n):
    sum += 1.0/a[i]
print(1/sum)


Measured memory_bytes: 3444