akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};
    
int main() {
    int N; cin >> N;
    vector<long long> x(N), y(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

    // Kruskal 法で使用する枝
    using pint = pair<int,int>;
    using Edge = pair<long long, pint>;
    vector<Edge> edges;

    // x 軸方向にソートして隣接している部分のみ
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(x[v] - x[u], pint(u, v)));
    }

    // y 軸方向にソートして隣接している部分のみ
    sort(ids.begin(), ids.end(), [&](int i, int j) { return y[i] < y[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(y[v] - y[u], pint(u, v)));
    }

    // Kruskal 法
    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    long long res = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        long long cost = e.first;
        if (uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}


Measured memory_bytes: 8304
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int[] an = new int[a];
		int[] bn = new int[b];
		int m = saori.saori_hayami();
		for(int i = 0;i < a;i++){
			an[i] = saori.saori_hayami();
		}
		for(int i = 0;i < b;i++){
			bn[i] = saori.saori_hayami();
		}
		int ans = MAX;
		for(int i = 0;i < m;i++){
			int x = saori.saori_hayami() - 1;
			int y = saori.saori_hayami() - 1;
			int c = saori.saori_hayami();
			ans = Math.min(ans,an[x]+bn[y] - c);
		}
		Arrays.sort(an);
		Arrays.sort(bn);
		ans = Math.min(an[0] + bn[0],ans);
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 29368
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)

using pii = pair<int, int>;
using vpii = vector<pii>;

int n, m, p, q, r;

int calc(pii seg, int n) // n=seg.fst????????????????????????
{
	int len = seg.scd - seg.fst + 1; // seg?????????

	if (n < p && p <= n + len - 1) {
		int a = (n + len - 1) - p;

		return calc(pii(seg.scd - a, seg.scd), p);
	}

	if (p <= n && n + len - 1 <= q) {
		return max(min(r - seg.fst + 1, len), 0);
	}

	if (n <= q && q < n + len - 1) {
		int a = q - n;

		return calc(pii(seg.fst, seg.fst + a), n);
	}

	return 0;
}

int main()
{
	omajinai;

	while (cin >> n >> m >> p >> q >> r, n) {
		deque<pii> dat;

		dat.push_back(pii(1, n));

		rep(_, m) {
			int x, y; cin >> x >> y;

			int sum = 0;

			vpii Top, Mid, Bottom;

			// Top?????????
			while (true) {
				pii a = dat.front();

				int v = a.scd - a.fst + 1;

				if (sum + v >= x) {
					int dif = x - sum-1;

					sum += dif + 1;

					Top.push_back(pii(a.fst, a.fst + dif));

					dat.pop_front();

					if (a.fst + dif + 1 <= a.scd) dat.push_front(pii(a.fst + dif + 1, a.scd));

					break;
				} else {
					Top.PB(a);
					sum += v;
				}

				dat.pop_front();
			}

			// Mid?????????
			while (true) {
				pii a = dat.front();

				int v = a.scd - a.fst + 1;

				if (sum + v >= y) {
					int dif = y - sum-1;

					sum += dif + 1;

					Mid.push_back(pii(a.fst, a.fst + dif));

					dat.pop_front();

					if (a.fst + dif + 1 <= a.scd) dat.push_front(pii(a.fst + dif + 1, a.scd));

					break;
				} else {
					Mid.PB(a);
					sum += v;
				}
				dat.pop_front();
			}

			// Bottom?????????
			while (true) {
				pii a = dat.front();

				int v = a.scd - a.fst + 1;

				if (sum + v == n) {
					sum += v;

					Bottom.push_back(pii(a.fst, a.scd));

					dat.pop_front();

					break;
				} else {
					Bottom.PB(a);
					sum += v;
				}

				dat.pop_front();
			}

			rep(i, Bottom.size()) dat.push_back(Bottom[i]);
			rep(i, Mid.size()) dat.push_back(Mid[i]);
			rep(i, Top.size()) dat.push_back(Top[i]);
		}

		int sum = 1;
		int ans = 0;

		for (pii a : dat) {
			ans += calc(a, sum);
			sum += a.scd - a.fst + 1;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
int a[16];
int x[16][16],y[16][16];

int main() {

	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		rep(j,a[i])cin>>x[j][i]>>y[j][i];
	}
	int ans=0;
	for(int i=1; i<(1<<n); i++){
		int f=0,t=0;
		rep(j,n){
			if(i&(1<<j)){
				rep(k,a[j]){
					if(i&(1<<(x[k][j]-1))){
						if(y[k][j]==0)f=1;
					}else{
						if(y[k][j]==1)f=1;
					}
				}
				t++;
			}
			if(f==1)break;
		}
		if(f==0)ans=max(ans,t);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s[n];
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string _s;
        cin >> _s;
        if (mp.count(_s) != 0) {
            mp[_s] += 1;
        } else {
            mp[_s] = 1;
        }
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string _s;
        cin >> _s;
        if (mp.count(_s) != 0) {
            mp[_s] -= 1;
        }
    }

    int ret = 0;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        int cnt = it->second;
        if (cnt > ret) {
            ret = cnt;
        }
    }

    cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 105;
int a[N];
int main()
{
    int n,m,s = 0;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)   scanf("%d",&a[i]),s+=a[i];
    sort(a+1,a+n+1,greater< int >());
    printf(a[m]>=(s+4*m-1)/(4*m) ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int a, b, n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
	}
	else{
			cin >> a >> b;
			cout << a + b << endl;
	}
	

						
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

const int INF=100000000;
const int MAX_N=1010, MAX_M=1010;
char maze[MAX_N][MAX_M+1];
int N, M;
int sx, sy;
int gx, gy;
vector<P> s;
int d[MAX_N][MAX_M];

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

void bfs(){
    queue<P> que;
    
    rep(i,0,N)
    rep(j,0,M) d[i][j]=INF;
    for(auto in : s){
        que.push(in);
        d[in.fr][in.sc]=0;
    }
    while(que.size()){
        P p=que.front(); que.pop();
        rep(i,0,4){
            int nx=p.first+dx[i], ny=p.second+dy[i];
            
            if (0<=nx && nx<N && 0<=ny && ny<M &&  d[nx][ny]>d[p.fr][p.sc]+1){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,N){
        rep(j,0,M){
            cin>>maze[i][j];
            if(maze[i][j]=='#') s.pb(P(i,j));
        }
    }
    bfs();
    int ma=-1;
    rep(i,0,N){
        rep(j,0,M){
            ma=max(ma,d[i][j]);
        }
    }
    cout <<ma<<"\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	std::cout.precision(18);

    double t, x;

	cin >> t >> x;

	Out(t / x);
	
	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        var N = long.Parse(Console.ReadLine());

        var sum = 0L;
        for (int i = 1; i < N + 1; i++)
        {
            var q = N / i;
            sum += q * (q + 1) * i / 2;
        }
        Console.WriteLine(sum);
    }
}


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

int main() {
    ll N,M;cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0;i < N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    P X[M] = {};
    for (int i = 0;i < M;i++){
        cin >> X[i].second >> X[i].first;
    }
    sort(X,X + M);
    int a = 0;ll res = 0;int flag = 0;
    for (int i = M - 1;i >= 0;i--){
        ll b = X[i].second;ll c = X[i].first;
        for (int j = 0;j < b;j++){
            if (A[a] < c){
                A[a] = c;
                a++;
            }
            else{
                flag = 1;
                break;
            }
        }
        if (flag == 1) break;
    }
    for (int i = 0;i < N;i++){
        res += A[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
N,A,B = map(int,input().split())
S = input()

ok = foreign = 0
for c in S:
    if c=='a':
        if ok < A+B:
            ok += 1
            print('Yes')
            continue
    elif c=='b':
        if ok < A+B and foreign < B:
            ok += 1
            foreign += 1
            print('Yes')
            continue
    print('No')

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int n,m,maxi,temp=0;
//int arr[1000000];
int level[1000000];
vector<vector<int>> v;
void dfs(int i)
{
    temp++;
    level[i]=1;
    int j=0;
    while(j<(int)(v[i].size()))
    {
        if(level[v[i][j]]==-1)
        dfs(v[i][j]);
        j++;
    }
}
int main()
{
    cin>>n>>m;
    //memset(arr,-1,sizeof(arr));
    memset(level,-1,sizeof(level));
    int i=0;
    v.resize(n+1);
    set<pair<int,int>> s;
    while(i<m)
    {
        int a,b;
        cin>>a>>b;
        pair<int,int> p;
        if(a>b)
            p=make_pair(b,a);
        else
            p=make_pair(a,b);
        if(s.find(p)==s.end())
        {
            v[a].push_back(b);
            v[b].push_back(a);
            s.insert(p);
        }
        i++;
    }
    maxi=INT_MIN;
    i=1;
    while(i<=n)
    {
        if(level[i]==-1)
        {
            dfs(i);
            maxi=max(maxi,temp);
            temp=0;
        }
        i++;
    }
    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 36688
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    int cnt = 0;

    for(int i=1;i<=n;i++){
        if(i%2==1) cnt++;
    }

    cout << setprecision(50) << (cnt+0.0)/(n+0.0) << endl;
    

    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int s = int.Parse(Console.ReadLine());
        int[] b = new int[1000000];
        b[s]++;
        for(int i = 2; i <= 1000000; i++)
        {
            if(s % 2 == 0)
            {
                s = s / 2;
            }
            else
            {
                s = 3 * s + 1;
            }
            b[s]++;
            
            if(b[s] == 2)
            {
                Console.WriteLine(i);
                break;
            }
        }

        
    }
}

Measured memory_bytes: 11088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    vector<int> ans(N+1,0);

    rep(x,1,101) rep(y,1,101) rep(z,1,101) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v <= N) ans[v]++;
    }

    rep(i,1,N+1) cout << ans[i] << endl;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {

	public static boolean isOK(int i, int j) {
		char[] str_i = String.valueOf(i).toCharArray();
		char[] str_j = String.valueOf(j).toCharArray();
		
		return str_i[0] == str_j[str_j.length - 1] && str_i[str_i.length -1] == str_j[0];
	}
	
	public static Integer hash(int n) {
		char[] str = String.valueOf(n).toCharArray();
		if(str[0] == '0' || str[str.length -1] == '0') {
			return -1;
		}
		String a = String.valueOf(new char[] {str[0], str[str.length -1]});
		
		
		return Integer.parseInt(a);
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		Map<Integer, List<Integer>> map = new HashMap<>();
		
		
		for(int i=1; i<=9;i++) {
			for(int j=1; j<=9;j++) {
				map.put(i*10 + j, new ArrayList<Integer>());	
			}
		}
		
		
		for(int i=1; i<=n;i++) {
			int h = hash(i);
			if(h <= 0) {
				continue;
			}
			
			List<Integer> l = map.get(h);
			l.add(i);
			map.put(h, l);
		}
		


		int ans = 0;

		for(int i=1; i<=9; i++) {
			for(int j=1; j<=9; j++) {
				int a = map.get(i*10 + j).size();
				int b = map.get(j*10 + i).size();
				ans += a * b;
				
			}
		}
		
		System.out.println(ans);
		
	}
	


}

 

Measured memory_bytes: 46460
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
 
int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x.at(i).at(j);
        }
    }
    int count = 0;
    double dis;
    int diss;
    for (int i  = 0; i < n; i++) {
        for (int j  = i + 1; j < n; j++) {
            dis = 0;
            for (int k = 0; k < d; k++) {
                dis += (x.at(i).at(k) - x.at(j).at(k)) * (x.at(i).at(k) - x.at(j).at(k));
            }
            dis = sqrt(dis);
            diss = (int)(dis / 1);
            if (dis == diss) count++;
        }
    }
    cout << count << endl;
}

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

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

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

struct Data {
    int dist;
    int y;
    int x;

    Data(int dist0, int y0, int x0) {
        dist = dist0;
        y = y0;
        x = x0;
    }
};

int bfs(Vec<Vec<int> >& table, int h, int w) {
    queue<Data> que;
    Data start(0, 1, 1);
    table[start.y][start.x] = 1;
    que.push(start);

    while (!que.empty()) {
        Data now = que.front();
        que.pop();
        if (now.y == 2 * h - 1 && now.x == 2 * w - 1) {
            return now.dist;
        }
        for (int i = 0; i < 4; i++) {
            if (table[now.y + dy[i]][now.x + dx[i]] != 1) {
                table[now.y + dy[i]][now.x + dx[i]] = 1;
                Data new_insert(now.dist + 1, now.y + dy[i], now.x + dx[i]);
                que.push(new_insert); 
            }
        }
    }

    return 0;
}

void dump(Vec<Vec<int> >& table) {
    for (int i = 0; i < (int)table.size(); i++) {
        for (int j = 0; j < (int)table[0].size(); j++) {
            cout << table[i][j] << " ";
        }
        cout << endl;
    }
    return;
}

int main(void) {
    while (1) {
        int w;
        int h;
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }
        Vec<Vec<int> > table(2 * h + 1, Vec<int>(2 * w + 1, 0));
        for (int i = 0; i < 2 * w + 1; i++) {
            table[0][i] = 1;
            table[2 * h][i] = 1;
        }
        for (int i = 0; i < 2 * h + 1; i++) {
            table[i][0] = 1;
            table[i][2 * w] = 1;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                table[2 * (i + 1)][2 * (j + 1)] = 1;
            }
        }

        for (int i = 0; i < h - 1; i++) {
            for (int j = 0; j < w - 1; j++) {
                cin >> table[2 * i + 1][2 * (j + 1)];
            }
            for (int j = 0; j <= w - 1; j++) {
                cin >> table[2 * i + 2][2 * j + 1];
            }
        }
        for (int j = 0; j < w - 1; j++) {
            cin >> table[2 * (h - 1) + 1][2 * (j + 1)];
        }
        //dump(table);
        int ans = bfs(table, h, w);
        if (ans == 0) {
            cout << 0 << endl;
        } else {
            cout << ans / 2 + 1 << endl;
        }
    }
    return 0;
}

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

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

    int q;
    cin >> q;

    int l[q], r[q];
    int min_l = (int) 1e5;
    int max_r = 0;
    for (int i = 0; i < q; ++i) {
        cin >> l[i] >> r[i];
        min_l = min(min_l, l[i]);
        max_r = max(max_r, r[i]);
    }
    if (min_l == 1) min_l = 3;
    
    vector <int> prims;
    for (int num = min_l; num <= max_r; num += 2) {
        bool prim = true;
        for (int fac = 2; fac * fac <= num; ++fac) {
            if (num % fac == 0) {
                prim = false;
                break;
            }
        }
        if (!prim) continue;
        int num2 = (num + 1) / 2;
        for (int fac = 2; fac * fac <= num2; ++fac) {
            if (num2 % fac == 0) {
                prim = false;
                break;
            }
        }
        if (!prim) continue;
        prims.push_back(num);
    }

    for (int i = 0; i < q; ++i) {
        auto itr_l = lower_bound(prims.begin(), prims.end(), l[i]);
        auto itr_r = upper_bound(prims.begin(), prims.end(), r[i]);
        cout << itr_r - itr_l << '\n';
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin>>N>>K;
    int x[N];
    int xmi=0,xma=0;
    rep(i,N) {
        cin>>x[i];
    }
    int ans=INF;
    for(int i=0;i<N-K+1;i++){
        if(x[i+K-1]<=0) ans=min(ans,abs(x[i]));
        else if(x[i]<=0&&x[i+K-1]>=0) ans=min(ans,x[i+K-1]-x[i]+min(abs(x[i]),x[i+K-1]));
        else ans=min(ans,x[i+K-1]);

    }
    cout << ans << endl;

    




}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int pop();
void push(int);

int s[100],top = 0;

int main() {
  int x, y, z;
  char str[100];
  
  while(scanf("%s",str) != EOF) {
    if ( str[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    } else if ( str[0] == '-' ){
      x = pop();
      y = pop();
      push(y - x);
    } else if ( str[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    } else {
      z = atoi(str);
      push(z);
    }
  }
  printf("%d\n",pop());

  return 0;
}

int pop() {
  return s[--top];
}

void push(int n) {
  s[top++] = n;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int count1=0;
  int count2=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<100;j++){
      if(A.at(i)%2==0){
        count1++;
        A.at(i)/=2;
      }
      else{
        if(i==0){
          count2=count1;
          count1=0;
          break;
        }
        else{
          count2=min(count1, count2);
          count1=0;
          break;
        }
      }
    }
  }
  cout << count2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    string s,t; cin >> s >> t;
    vvl v(26);
    ll start = -1;
    rep(i,s.size()){
        v[s[i]-'a'].push_back(i);
    }
    rep(i,26){
        sort(all(v[i]));
    }
    ll ans = 0;
    rep(i,t.size()){
        if(v[t[i]-'a'].size() == 0){
            cout << -1 << endl;
            return 0;
        }else{
            auto itr = upper_bound(all(v[t[i]-'a']),start);
            if(itr == v[t[i]-'a'].end()){
                ans += s.size() + v[t[i]-'a'][0] - start;
                start = v[t[i]-'a'][0];
            }else{
                ans += *itr - start;
                start = *itr;
            }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>

using namespace std;

int main() {
	
	int n;
	cin >> n;
	
	int build[5][4][11] = { 0 };

	for (int i = 0; i < n; i++)	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		build[b][f][r] += v;
	}

	for (int i = 1; i <= 4; i++) {
		for (int j = 1; j <= 3; j++) {
			for (int k = 1; k <= 10; k++) {
				cout << " " << build[i][j][k];
			}
			cout << endl;
		}
		if (i < 4) {
			for (int v = 0; v < 20; v++) cout << "#";
			cout << endl;
		}
		
		
	}

	return 0;
}





Measured memory_bytes: 3096
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
C=[0]*N
for i in range(N):
  B[i]=A[i]+i+1
  C[i]=i+1-A[i]
B.sort()
C.sort()
start=0
j=0
bcount=1
bs=0
ans=0
for i in range(N-1):
  ccount=0
  x=B[i]
  
  if(x!=B[i+1]):
    bcount=i+1-bs
    #print(bcount)
    bs=i+1
    while(C[j]<=x):
      if(C[j]==x):
        ccount+=1
      if(j==N-1):
        break
      if(j<N-1):
        j+=1
      
    ans+=ccount*bcount
    #print(ccount)
#print(B)
#print(C)
print(ans)

Measured memory_bytes: 93036
import java.util.Scanner;

public class Main {
	static final int MAX = 1000;
    static final long INF = 1000000000000000l;
    static final int WHITE = 0;
    static final int GRAY = 1;
    static final int BLACK = 2;
    static int N, M;
    static Edge[]e;
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	N = sc.nextInt();
    	M = sc.nextInt();
    	e = new Edge[M];
    	for(int i = 0; i < M; i++) {
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		int c = sc.nextInt();
    		e[i] = new Edge(a - 1, b - 1, -c);
    	}
    	sc.close();
        //bellmanFord();
        if(bellmanFord()) {
            System.out.println("inf");
        }else {
        	System.out.println(-d[N - 1]);
        }
    }
    static long[]d = new long[MAX];
    static boolean bellmanFord() {
        for(int i = 0; i < MAX; i++) {
            d[i] = INF;
        }
        d[0] = 0;
        for(int i = 0; i < 2 * N; i++) {
            for(int j = 0; j < M; j++) {
                if(d[e[j].from] != INF && d[e[j].to] > d[e[j].from] + e[j].cost) {
                    d[e[j].to] = d[e[j].from] + e[j].cost;
                    if(i >= N - 1 && e[j].to == N - 1) return true;
                }
            }
        }
        return false;
    }
    static class Edge{
        int from, to;
        long cost;
        public Edge(int from, int to, long cost) {
            this.from = from;
            this.to= to;
            this.cost = cost;
        }
    }
}

Measured memory_bytes: 28488
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;cin>>a>>b>>k;
    for(int i=a;i<=min(b,a+k-1);i++){
        cout<<i<<endl;
    }
    for(int i=max(b-k+1,a+k);i<=b;i++){
        cout<<i<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,c) for (int i=0;i<c;i++)
using namespace std;
typedef long long ll;
 
 
int main(){
    ll H,W;
    cin >> H >> W;
    if( H ==1 || W == 1){
        cout << 1 <<endl; 
   }
    else{
        cout << (H*W+1)/2 <<endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	fmt.Println(a[len(a)-1] - a[0])
}


Measured memory_bytes: 512
import collections
n, m = map(int, input().split())

graph = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = collections.deque([(0, -1)])
visited = [None] * n
while que:
    p, parent = que.popleft()
    if visited[p] is not None:
        continue
    visited[p] = parent
    for to in graph[p]:
        que.append((to, p))

print("Yes")
for v in visited[1:]:
    print(v + 1)


Measured memory_bytes: 52136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    int cnt = 1;
    int ans = 0;
    while (cnt < b) {
        cnt--;
        cnt += a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define DELTA	((double)1e-10)
#define DIV	(40003)
#define PIDIV	(M_PI / DIV)

#define MAX_N	(20)
#define MAX_T	(20.0)

/* typedef */

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

struct rect_t {
  double x0, x1, h;
};

/* global variables */

int r, n;
rect_t rects[MAX_N];
double cosd[DIV + 1], sind[DIV + 1];

/* subroutines */

bool visible(double t) {
  double y0 = t - r;
  for (int d = 0; d <= DIV; d++) {
    double y = r * sind[d] + y0;
    if (y <= 0.0) continue;

    double x = r * cosd[d];

    bool covered = false;
    for (int i = 0; i < n; i++) {
      if (x >= rects[i].x0 && x <= rects[i].x1 && y <= rects[i].h) {
	covered = true;
	break;
      }
    }

    if (! covered) return true;
  }

  return false;
}

/* main */

int main() {
  for (int d = 0; d <= DIV; d++) {
    double th = PIDIV * d;
    cosd[d] = cos(th);
    sind[d] = sin(th);
  }

  for (;;) {
    cin >> r >> n;
    if ((r | n) == 0) break;

    for (int i = 0; i < n; i++)
      cin >> rects[i].x0 >> rects[i].x1 >> rects[i].h;

    double t0 = 0;
    double t1 = MAX_T;

    while (t1 - t0 > DELTA) {
      double t = (t0 + t1) / 2;
      if (visible(t))
	t1 = t;
      else
	t0 = t;
    }

    printf("%.4lf\n", t0);
  }

  return 0;
}

Measured memory_bytes: 1876
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] x=new long[n];
		long ans=0;
		for(int i = 0; i<n; i++){
			x[i]=sc.nextLong();
		}
		for(int i = 0; i<n-1; i++){
			ans+=Math.min(b,(x[i+1]-x[i])*a);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60144
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 069c
int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    int even=0, odd=0, four=0;
    rep(i, n){
        int tmp = a[i];
        if(a[i]%2==0){
            even++;
            if(a[i]%4==0) four++;
        }else odd++;
    }
    if (even==n){
        cout << "Yes" << endl;
        return 0;
    }
    if(n%2==0){
        if(four >= odd) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        if(four >= odd-1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll N,M,K; cin>>N>>M>>K;
  vector<vector<ll>> friend_graph(N,vector<ll>(0)); 
  rep(i,M){
    ll A,B; cin>>A>>B; A--,B--;
    friend_graph.at(A).push_back(B);
    friend_graph.at(B).push_back(A);
  }
  vector<vector<ll>> block_graph(N,vector<ll>(0));
  rep(i,K){
    ll C,D; cin>>C>>D; C--,D--;
    block_graph.at(C).push_back(D);
    block_graph.at(D).push_back(C);
  }
  
  //ラベル張り
  vector<ll> union_(N,-1);
  ll label=0;
  rep(i,N){
    if(union_[i]>-1) continue;
    union_[i]=label;
    queue<ll> que; que.push(i);
    while(!que.empty()){
      ll v=que.front(); que.pop();
      for(auto nv:friend_graph.at(v)){
        if(union_[nv]>-1) continue;
        union_[nv]=label;
        que.push(nv);
      }
    }
    label++;
  }
  label--;
  
  //それぞれのunionの所属数
  vector<ll> union_num(label+1,0);
  for(auto num:union_) union_num[num]++;
  
  //for(auto num:union_num) cout<<num<<endl;
  
  //ブロック関係と友達関係を考えないときの答え
  vector<ll> vec(N);
  rep(i,N) vec[i]=union_num[union_[i]];
  
  //rep(i,N) {if(i!=0) cout<<" "; cout<<vec[i];} cout<<endl;
  
  //友達と自分削除
  rep(i,N) vec[i]-=friend_graph[i].size()+1;
  
  //rep(i,N) {if(i!=0) cout<<" "; cout<<vec[i];} cout<<endl;
  
  //ブロック関係削除
  rep(i,N){
    for(auto v:block_graph.at(i)){
      if(union_[i]==union_[v]) vec[i]--;
    }
  }
  
  rep(i,N){
    if(i!=0) cout<<" ";
    cout<<vec[i];
  }
  cout<<endl;
  
  return 0;
}

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

int main()
{
    int n;
    double m,s;
    while(cin >> n){
        int h[n];
        if(n == 0){
            break;
        }
        s = 0;
        for(int i = 0; i < n;i++){
            cin >> h[i];
            s += h[i];
        }
        s /= n;
        m = 0;
        for(int i = 0; i < n; i++){
            m += pow(h[i] - s, 2);
        }
        m /= n;
        m = sqrt(m);
        cout << m << endl;
    }
    return 0;
}


Measured memory_bytes: 3304
k,n = map(int,input().split())
a = list(map(int,input().split()))
t = 10 ** 6

for i in range(n - 1):
    a.append(a[i] + k)

for i in range(len(a)-n+1):
    t = min(t,a[i+n-1] - a[i])

print(t)

Measured memory_bytes: 32224
while 1:
    n = input()
    if n==0:
        break
    A = map(int, raw_input().split())
    ans = 1e18
    for i in xrange(n):
        for j in xrange(n):
            if i==j: continue
            ans = min(ans, abs(A[i]-A[j]))
    print ans

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;
template <typename T, typename A>
ostream& operator<<(ostream& os, const vector<T, A>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

inline ll rt(const ll n)
{
    ll inf = 0;
    ll sup = sqrt(n) * 2;
    while (sup - inf > 1) {
        const ll mid = (inf + sup) / 2;
        const ll v = mid * mid;
        if (v == n) {
            return mid;
        } else if (v < n) {
            inf = mid;
        } else {
            sup = mid;
        }
    }
    return inf * inf == n ? inf : sup * sup == n ? sup : 0;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }

    constexpr ll MAX = 10000000000;
    const ll CBRT = 143;
    vector<bool> isprime(CBRT, true);
    vector<ll> prime;
    for (ll i = 2; i < CBRT; i++) {
        if (isprime[i]) {
            prime.push_back(i);
            for (ll j = 2; i * j < CBRT; j++) {
                isprime[i * j] = false;
            }
        }
    }
    vector<ll> t(N, 1);
    for (int i = 0; i < N; i++) {
        ll S = s[i];
        for (const ll p : prime) {
            const ll d3 = p * p * p;
            while (s[i] % d3 == 0) {
                s[i] /= d3;
                S /= d3;
            }
            int ind = 0;
            for (; S % p == 0; ind++) {
                S /= p;
            }
            if (ind == 2) {
                t[i] *= p;
            } else if (ind == 1) {
                t[i] *= p * p;
            }
        }
        const ll r = rt(S);
        if (r == 0) {
            t[i] *= S * S;
        } else {
            t[i] *= r;
        }
    }
    using P = pair<ll, ll>;
    set<P> v;
    for (int i = 0; i < N; i++) {
        v.insert({s[i], t[i]});
    }
    sort(s.begin(), s.end());
    const auto find = [&](const ll e) {
        return (int)(upper_bound(s.begin(), s.end(), e) - lower_bound(s.begin(), s.end(), e));
    };
    ll ans = 0;
    set<ll> used;
    for (const auto p : v) {
        const ll e1 = p.first;
        const ll e2 = p.second;
        if (used.find(e1) != used.end()) continue;
        if (e1 == 1) {
            ans += 1;
            used.insert(1);
            continue;
        }
        used.insert(e1);
        used.insert(e2);
        ans += max(find(e1), find(e2));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17408
# 日本では、3 月 3 日にひなあられという、色のついたお菓子をお供えする習慣があります。
# 1 つの袋があり、ひなあられが N 個入っています。
# この袋には、桃色、白色、緑色の 3 種類か、
# 桃色、白色、緑色、黄色の 4 種類のひなあられが入っていることが分かっています。
# 桃色を P、白色を W、緑色を G、黄色を Y と表したとき、
# 袋からひなあられを 1 粒ずつ取り出していったところ、
# i 番目に取り出したひなあられの色は Si でした。
# この袋に 3 種類のひなあられが入っていた場合は Three、
# 4 種類のひなあられが入っていた場合は Four と出力してください。

n = gets.to_i
s = gets.chomp.split

colors = {
  "p": false,
  "w": false,
  "g": false,
  "y": false
}

n.times do |i|
  case s[i]
  when "P"
    colors[:p] = true
  when "W"
    colors[:w] = true
  when "G"
    colors[:g] = true
  when "Y"
    colors[:y] = true
  end
end

if colors[:p] && colors[:w] && colors[:g] && colors[:y]
  puts "Four"
elsif colors[:p] && colors[:w] && colors[:g]
  puts "Three"
end


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
	int i,j,k,m,n;
	cin>>n>>m>>k;
	for(i=0;i<=n;i++){
		int t=m*i;
		for(j=0;j<=m;j++)
			if(t+(n-i)*j-i*j==k){
				cout<<"Yes";
				return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int d[100] = {};

int main(void)
{

	int n,answer = 1,a = 0;
	cin >> n;

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

	sort(d,d+n);

	for (int i = 0; i < n; i++) {
		if (d[a] < d[i]) {
			answer++;
			a = i;
		}
	}

	cout << answer << endl;

	return 0;
}



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

int main()
{
   int N,D;
   std::cin >> N >> D;
   float b=2*D+1;
   float c=N;
   float a=c/(b);
   int j=std::ceil(a);
    std::cout << j << std::endl;
    return 0;
}

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

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

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;

    return 0;
}

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

int main(){
  int i,j;ll cnt=0;
  int h,w,k;
  cin>>h>>w>>k;
  string s[h];
  for(i=0;i<h;i++)cin>>s[i];
  int x[k],y[k];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i][j]=='#'){
        x[cnt]=i;
        y[cnt++]=j;
      }
    }
  }
  int p[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)p[i][j]=0;
  }
  for(i=0;i<k;i++)p[x[i]][y[i]]=i+1; 
  cnt=0;
  for(i=0;i<k;i++){
    int left=y[i],right=y[i];
    j=x[i];
    while(left!=0 && p[j][left-1]==0){
      left--;
      p[j][left]=p[j][y[i]];
    }
    while(right!=w-1 && p[j][right+1]==0){
      right++;
      p[j][right]=p[j][y[i]];
    }
  }
  if(h!=1){
    for(i=0;i<w;i++){
      if(p[0][i]==0){
        for(j=1;j<h;j++){
          if(p[j][i]!=0){
            p[0][i]=p[j][i];
            break;
          }
        }
      }
    }
  }
  for(i=1;i<h;i++){
    for(j=0;j<w;j++){
      if(p[i][j]==0)p[i][j]=p[i-1][j];
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w-1;j++){
      cout<<p[i][j]<<" ";
    }
    cout<<p[i][w-1]<<endl;
  }
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;


int main(){

    int n;
    cin >> n;

    vector<int> v;

    rep(i,n){
        int tmp;
        cin >> tmp;
        v.pback(tmp);
    }

    int ans = INT_MAX;

    for(int i = 1; i <= 100; i++){

        int tmp = 0;

        rep(j, n){
            tmp += (v[j] - i) * (v[j] - i); 
        }

        ans = min(ans, tmp);

    }


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


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

using namespace std;

#define mp make_pair
#define PI acos(-1)
#define TASK "hz"                     
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> pii; 
typedef vector <pii> vpii;

void solve() {
	
}

void read() {
	ll a, b, c;                            
	cin >> a >> b >> c;
	ll ansa = (a / 2) * b * c - (a / 2 + a % 2) * b * c;
	ll ansb = (b / 2) * a * c - (b / 2 + b % 2) * a * c;
	ll ansc = (c / 2) * a * b - (c / 2 + c % 2) * a * b;
	cout << min(abs(ansa), min(abs(ansb), abs(ansc))) << endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif
	read();
	solve();
	return 0;	
}

Measured memory_bytes: 256