akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,K;
  cin >> N >> K;

  vector<int> a(N);
  for(int i=0;i<N;i++){
    int t; cin >> a[i];
  }

  vector<int> r(K+1,0);

  for(int i=0;i<=K;i++){
    for(int j=0;j<N;j++){
      if(a[j]<=i){
        if(r[i-a[j]]==0){
          r[i]=1;
          break;
        }
      }
    }
    //cout << i << " " << r[i] << endl;
  }

  if(r[K]==0) cout << "Second" << endl;
  else cout << "First" << endl;
  return 0;
}


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

using namespace std;

int main(){
    while(true){
        vector<int> vals(5,0);
        bool valid=true;
        for(int i=0;i<5;i++){
            cin>>vals[i];
            int v=0;
            cin>>v;
            vals[i]+=v;
            if(vals[i]==0){
                valid=false;
                break;
            }
        }
        if(!valid)break;

        int max_i=0;
        for(int i=1;i<5;i++){
            if(vals[i]>vals[max_i])max_i=i;
        }

        cout<<(char)(max_i+'A')<<" "<<vals[max_i]<<endl;
    }
}


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

string s;
int ta[4] = {};

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N') {
			ta[0]++;
		}
		else if (s[i] == 'W') {
			ta[1]++;
		}
		else if (s[i] == 'S') {
			ta[2]++;
		}
		else {
			ta[3]++;
		}
	}
	if (ta[0] == 0 && ta[2] != 0 || ta[2] == 0 && ta[0] != 0) {
		cout << "No" << endl;
		return 0;
	}
	if (ta[1] == 0 && ta[3] != 0 || ta[3] == 0 && ta[1] != 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

const int N = 4100;
char to[N][N][4], was[N][N];

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    vi dx = {-1, 0, 1, 0};
    vi dy = {0, 1, 0, -1};
    cin >> n >> m;
    vi a(n), b(n), c(n);
    map <int, int> from_x, from_y;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        from_x[a[i]] = 0;
        from_x[b[i]] = 0;
        from_y[c[i]] = 0;
    }
    vi d(m), e(m), f(m);
    for (int i = 0; i < m; i++) {
        cin >> d[i] >> e[i] >> f[i];
        from_x[d[i]] = 0;
        from_y[e[i]] = 0;
        from_y[f[i]] = 0;
    }    

    from_x[0] = 0;
    from_y[0] = 0;

    vi to_x(sz(from_x) + 10), to_y(sz(from_y) + 10);

    int kx = 1;
    for (auto & q : from_x) {
        q.se = kx;
        to_x[kx] = q.fi;
        kx++;
    }
    
    int ky = 1;
    for (auto & q : from_y) {
        q.se = ky;
        to_y[ky] = q.fi;
        ky++;
    }
    
    for (int i = 0; i < n; i++) {
        int xa = from_x[a[i]], xb = from_x[b[i]], yc = from_y[c[i]];
        for (int j = xa; j < xb; j++) {
            to[j][yc - 1][1] = -1;
            to[j][yc][3] = -1;
        }
    }
    for (int i = 0; i < m; i++) {
        int xd = from_x[d[i]], ye = from_y[e[i]], yf = from_y[f[i]];
        for (int j = ye; j < yf; j++) {
            to[xd][j][0] = -1;
            to[xd - 1][j][2] = -1;
        }
    }
    vii q = {{from_x[0], from_y[0]}};
    ll ans = 0;
    was[q[0].fi][q[0].se] = 1;
    for (int l = 0; l < sz(q); l++) {
        ii cur = q[l];
        int x = cur.fi, y = cur.se;
        if (x == 0 || y == 0 || x == kx - 1 || y == ky - 1) {
            cout << "INF" << endl;
            re 0;
        }
        ans += ((ll)to_x[x + 1] - to_x[x]) * (to_y[y + 1] - to_y[y]);
        for (int k = 0; k < 4; k++) {
            int xc = cur.fi + dx[k], yc = cur.se + dy[k];
            if (to[x][y][k] != -1 && !was[xc][yc]) {
                q.pb(mp(xc, yc));
                was[xc][yc] = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 190948
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s,t;
  cin >> s >> t;
  int n = len(s), m = len(t);
  int ans = 100000000;
  rep(i,0,n-m+1) {
    int k = 0;
    rep(j,0,m) {
      if (s[i+j] != t[j]) k++;
    }
    ans = min(ans,k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
using namespace std;


int main() {
	int a = 0;
	int b = 0;

	cin >> a >> b;

	cout << (a + b + 1) / 2 << endl;

	return 0;
}

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

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

int n;
long long arr[200],ggcd,a;

int main(){
	
	scanf("%d",&n);
	a = 1;
	for(int i = 1;i <= n;i++){
		scanf("%lld",&arr[i]);
		ggcd = gcd(a,arr[i]);
		a = a/ggcd*arr[i];
	}
	
	printf("%lld",a);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int N, P[1010], X[1010];
vi C[1010];
bool flag = true;

pi dfs(int idx) {
    int First = 0;
    itn Second = 0;
    itn SUM = 0;
    bitset<5555> BIT(1);
    for (auto& nxt : C[idx]) {
        auto tmp = dfs(nxt);
        int a = tmp.first;  /*  //部分木の重い色の和*/
        int b = tmp.second; /*  //部分木の軽い色の和*/
        //ナップサック？

        BIT <<= b;
        BIT |= (BIT << (a - b));

        // BIT = (BIT << a) | (BIT << b);

        SUM += a + b;
        Second += b;
        First += a;
    }

    /*
    if (First <= X[idx]) {
        return {X[idx], Second};
    }
    */

    for (int i = X[idx]; i >= 0; i--) {
        if (BIT[i]) {
            //大小を保証
            if (SUM - i >= X[idx])
                return {SUM - i, X[idx]};
            else
                return {X[idx], SUM - i};
        }
    }
    //Impossible
    flag = false;
    return {0, 0};
}

void solve() {
    dfs(0);
    if (flag)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
}

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

    cin >> N;
    FOR(N - 1) {
        cin >> P[i];
        P[i]--;
        C[P[i]].eb(i + 1);
    }
    FOR(N) {
        cin >> X[i];
    }

    solve();
    return 0;
}


Measured memory_bytes: 1280
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * https://abc045.contest.atcoder.jp/tasks/arc061_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
		
		int N = 1<<s.length-1;
		long sum = 0;
		for(int b=0; b<N; b++){
			List<Long> list = new ArrayList<>();
			StringBuilder sb = new StringBuilder();
			sb.append(s[0]);
			for(int i=1; i<s.length; i++){
				if((b&(1<<(i-1)))>0){
					list.add(Long.parseLong(sb.toString()));
					sb = new StringBuilder();	
				}
				sb.append(s[i]);
			}
			if(sb.length()>0) list.add(Long.parseLong(sb.toString()));
			for(long n:list){
				sum += n;
			}
		}
		
		System.out.println(sum);
	}

}

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

int main(){
	int X;
	cin >> X;

	if (X < 100) cout << 0 << endl;
	else if (X >= 2000) cout << 1 << endl;
	else if ((X / 100) * 5 >= X % 100) cout << 1<< endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) {
		final FastScanner sc = new FastScanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		System.out.println(z + " " + x + " " + y);
	}

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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


Measured memory_bytes: 21204
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<int> V(N,0),T(N,0);
	REP(i,N){
		V[i]=in();
		if(i==0) T[i]=V[i];
		else T[i] = min(T[i-1],V[i]);
	}
	
	int S=0;
	REP(i,N){
		if(i==0) S++;
		else{
			if(V[i]<T[i-1]) S++;
		}
	}

	out(S);
	return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k,ans=0;
	cin >> n >> k;
	vector<int> v(n);
	for(auto &x:v){
		cin >> x;
		if(x >= k) ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) {
    cout << "Left" << endl;
  }else if (a + b < c + d) {
    cout << "Right" << endl;
  }else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;

  int64_t A,B;
  vector<pair<int64_t,int64_t>> p(N);

  for(int i=0;i<N;++i){
    cin>>A>>B;
    p.at(i)=make_pair(A,B);
  }

  sort(p.begin(),p.end());
  priority_queue<int64_t> pq;

  int64_t sum=0;
  int index=0;

  for(int i=1;i<=M;++i){
    while(index<N && p.at(index).first<=i){
      pq.push(p.at(index).second);
      ++index;
    }
    if(!pq.empty()){
    sum+=pq.top();
    pq.pop();
    }
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 2936
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;


public class Main {

	static List[] arLs;
	static boolean[] visited;
	static int[] dist;
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		arLs = new List[n];
		visited = new boolean[n];
		dist = new int[n];
		for (int i=0;i<n;i++) {
			dist[i] = -1;
		}
		for (int i=0;i<n;i++) {
			List<Integer> ls = new ArrayList<Integer>();
			scan.nextInt();
			int np = scan.nextInt();
			for (int j=0;j<np;j++) {
				ls.add(scan.nextInt()-1);
			}
			arLs[i] = ls;
		}
		
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(0);
		dist[0] = 0;
		visited[0] = true;
		while (!q.isEmpty()) {
			int now = (Integer) q.poll();
			for (int i=0;i<arLs[now].size();i++) {
				int next = (Integer) arLs[now].get(i);
				if (visited[next]) continue;
				visited[next] = true;
				dist[next] = dist[now]+1;
				q.add(next);
			}
		}
		for (int i=0;i<dist.length;i++) {
			System.out.println((i+1)+" "+dist[i]);
		}
	}
}

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

const int INF =1e9;
const int MOD =1e9+7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

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

int main()
{
    int n,m;
    cin>>n>>m;
    REP(i,m){
        int a;
        cin>>a;
        n-=a;
    }
    cout<<max(-1,n)<<endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#define maxn 100010
using namespace std;
char in[3];
int n,v[3],p[maxn],q[maxn],ans[maxn];
int main(){
	int i;
	scanf("%d",&n);
	for(i=0;i<3;i++)scanf("%d",&v[i]);//v[0]代表'A'的数量,v[1]代表'B'的数量,v[2]代表'C'的数量
	for(i=1;i<=n;i++)scanf("%s",in),p[i]=in[0]-'A',q[i]=in[1]-'A';
	for(i=1;i<=n;i++){
		if(v[p[i]]>v[q[i]])swap(p[i],q[i]);//让v[]小的在前
		else if(v[p[i]]==v[q[i]]){
			if(i+1<=n&&(q[i]==p[i+1]||q[i]==q[i+1]))swap(p[i],q[i]);//让接下来马上要用到的,在前
		}
		if(!v[q[i]])return 0*printf("No\n");
		v[p[i]]++,v[q[i]]--,ans[i]=p[i];
	}
	printf("Yes\n");
	for(i=1;i<=n;i++)printf("%c\n",'A'+ans[i]);
	return 0;
}

Measured memory_bytes: 2908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

int n, x;
int pre(int i) {
  if (i == 0) return n-1;
  return i-1;
}

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

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

  const ll INF = 1LL << 50;
  vector<vector<ll>> cost(n, vector<ll>(n, INF));
  rep(i, n) cost[0][i] = a[i];

  rep(i, n-1) {
    rep(j, n) {
      cost[i+1][j] = min(cost[i][j], cost[i][pre(j)]);
    }
  }

  ll ans = INF;
  rep(i, n) {
    ll costsum = 0;
    rep(j, n) {
      costsum += cost[i][j];
    }
    cmin(ans, costsum + i * x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 31616
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define d double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  size_t n =s.size();
  int i;
  for(i=0;i<n;i++){
  	cout<<"x";
  }
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 3648
n , D =map(int,input().split())
import math
 
a = [input().split() for l in range(n)]
count = 0
 
for i in range(n):
  for j in range(n):
    if i == j:
      count += 0
    else:
      x = []
      for c in range(D):
        x.append((int(a[i][c]) - int(a[j][c])) ** 2)
      d = math.sqrt(sum(x))
      d = float(d)
      if d.is_integer():
        count += 1
print(int(count/2))

Measured memory_bytes: 3064
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
temp = abs(A - (T - (H[0] * 0.006)))
result = 1
for i in range(1, N):
    temp2 = abs(A - (T - (H[i] * 0.006)))
    if temp > temp2:
        temp = temp2
        result = i + 1

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
const double pi = 3.1415926535;
int main(){
    int A,B,H,M;
    long double ang_H,ang_M,rad;
    cin>>A>>B>>H>>M;
    ang_H=30*H+0.5*M;
    ang_M=6*M;
    rad=(ang_H-ang_M)*(pi/180);
    cout<<setprecision(10)<<sqrt((long double)(A*A)+(long double)(B*B)-2*A*B*(cos(rad)));
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define cs(ele) cout<<ele<<'\n'
int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  if(n%1000==0){cout<<0<<endl;}
  else{cout<<(n/1000+1)*1000-n<<endl;}

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  if(N<=9){
    ans = N;
  }
  else if(N>=10 && N<=99){
    ans = 9;
  }
  else if(N>=100 && N<=999){
    ans = N-100 +1 + 9;
  }
  else if(N>=1000 && N<=9999){
    ans = 909;
  }
  else if(N>=10000 && N<=99999){
    ans = N - 10000 + 1 +909;
  }
  else if(N == 100000){
    ans = 90909;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - HonestOrUnkind2
 */

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

/* constant */

const int MAX_N = 15;
const int NBITS = 1 << MAX_N;

/* typedef */

/* global variables */

int bnums[NBITS];
int hbs[MAX_N], ubs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    for (int j = 0; j < ai; j++) {
      int x, y;
      scanf("%d%d", &x, &y);
      x--;
      if (y == 1) hbs[i] |= (1 << x);
      else ubs[i] |= (1 << x);
    }
  }

  int nbits = 1 << n;
  bnums[0] = 0;
  for (int bits = 1, msb = 1; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
  }

  int maxbn = 0;
  for (int bits = 0; bits < nbits; bits++) {
    int hbits = 0, ubits = 0;
    for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
      if (bits & bi)
	hbits |= hbs[i], ubits |= ubs[i];
    if ((bits & hbits) == hbits && (bits & ubits) == 0 && maxbn < bnums[bits])
      maxbn = bnums[bits];
  }

  printf("%d\n", maxbn);
  return 0;
}


Measured memory_bytes: 384
while True:
    n , k = map(int,input().split())
    if (n,k) == (0,0): break
    a = [int(input()) for _ in range(n)]
    s = sum(a[0:k])
    l = [s]
    for i in range(k,n):
        s = s + a[i] - a[i-k]
        l.append(s)
    print(max(l))


Measured memory_bytes: 11700
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

int main(){
	ll k,a,b;cin>>k>>a>>b;
	if(b-a<=2){
		cout<<k+1<<endl;
		return 0;	
	}else{
		if(k+1<=a){
			cout<<k+1<<endl;return 0;
		}	
		ll c = a;
		k-=(a-1);
		if(k%2==0){
			c += (k/2)*(b-a);
		}else{
			c += (k/2)*(b-a);
			c++;
		}
		cout<<c<<endl;
	}	

}

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

int main()
{
    int a[26]={};
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        ++a[s[i]-'a'];
    for(int i=0;i<26;i++)
    {
        if(a[i]%2==1)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> P(3);
    cin >> P[0] >> P[1] >> P[2];
    int ans = 0;
    
    ans += *min_element(P.begin(), P.end());
    P.erase(min_element(P.begin(), P.end()));
    ans += *min_element(P.begin(), P.end());
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
// struct edge { int u, v, i; };
// ostream& operator<<(ostream& os, const edge& e) {
//     os << "(" << e.u << ", " << e.v << ")";
//     return os;
// }
// template <bool Directed> struct graph {
//     int n;
//     vector<edge> edges;
//     vector<vector<edge>> adj;
//     graph(int n) : n(n), adj(n + 1) {}
//     void add_edge(int u, int v) {
//         int i = edges.size();
//         edges.push_back({u, v, i});
//         adj[u].push_back({u, v, i});
//         if(not Directed) adj[v].push_back({v, u, i});
//     }
// };
// template <bool Directed> vector<int> bfs(graph<Directed>& g, int s, const function<void(int)>& f = [](int) {}) {
//     vector<int> d(g.n + 1, -1), p(g.n + 1);
//     d[s] = 0, p[s] = -1;
//     queue<int> q({s});
//     while(not q.empty()) {
//         int u = q.front(); q.pop();
//         f(u);
//         for(auto [u, v, i] : g.adj[u]) {
//             if(d[v] == -1) {
//                 d[v] = d[u] + 1, p[v] = u;
//                 q.push(v);
//             }
//         }
//     }
//     return d;
// }
// void check(vector<pair<int, int>>& ans, int n, int k) {
//     graph<0> g(n);
//     for(auto& p : ans) {
//         int u, v; tie(u, v) = p;
//         g.add_edge(u, v);
//     }
//     int counter = 0;
//     for(int i = 1; i <= n; i++) {
//         auto d = bfs(g, i);
//         counter += count(d.begin(), d.end(), 2);
//     }
//     err(counter, k);
//     assert(counter / 2 == k);
// }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> ans;
    if(k <= (n - 1) * (n - 2) / 2) {
        for(int j = 2; j <= n; j++) {
            ans.push_back({1, j});
        }
        int curr = (n - 1) * (n - 2) / 2;
        for(int i = 2; i <= n and curr > k; i++) {
            for(int j = i + 1; j <= n and curr > k; j++) {
                ans.push_back({i, j});
                curr--;
            }
        }
        cout << ans.size() << endl;
        for(auto& p : ans) {
            cout << p.first << " " << p.second << endl;
        }
        // check(ans, n, k);
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {

  int a, b;
  cin >> a >> b;
  cout << ((a*b)%2==0 ? "Even":"Odd") << endl;

  return 0;
}





// EOF


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

int A,B,C;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C;
    bool flag = false;

    if(A < C && B > C){
        flag = true;
    }else if(A > C && B < C){
        flag = true;
    }

    if(flag){ 
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c,d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int left = a+b;
  int right = c+d;
  if (left > right) {
    printf("Left\n");
  } else if (left == right) {
    printf("Balanced\n");
  } else {
    printf("Right\n");
  }

  return 0;
}

Measured memory_bytes: 128
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    cnt=0
    gr = groupby(A)
    for key, group in gr: # groupはイテレータ。list(group)でリスト化  
        """ex.
        0: [0, 0, 0]
        1: [1, 1]
        0: [0, 0, 0]
        1: [1, 1]
        0: [0]
        1: [1]
        """
        cnt+=len(list(group))//2

    
    print(cnt)
        
    


    
resolve()

Measured memory_bytes: 3064
MOD=10**9+7
mod=MOD
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans
Num,a,b=map(int,input().split())
Max=pow(2,Num,mod)
A=comb(Num,a)
B=comb(Num,b)
print((Max-A-B)%mod-1)

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

int main(){
  int num,ans = 0;
  
  cin >> num;
  
  while (num > 0){
    if ((num % 10) == 1){
      ans++;
    }
    num = num / 10;
  }
    
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

const int NMAX = 5005;

int n, dp[NMAX][NMAX], ans;
string s;


int main()
{
	cin >> n >> s;
	s = " " + s;
	for (int i = 1;i <= n;++i)
		for (int j = 1;j <= n;++j)
		{
			if (s[i] == s[j])
				dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]);
			else
				dp[i][j] = 0;
			dp[i][j] = min(dp[i][j], j - i);
			ans = max(ans, dp[i][j]);
		}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 98048
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    double n,num;
    cin >> n;
    for(double i=1;i<10;i++){
        num=n/i;
        if(floor(num)==num&&num>=1&&num<=9){
            cout<<"Yes";
            break;
        }else if(i==9){
            cout<<"No";
        }
    }
}


Measured memory_bytes: 256
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int A, B;
    cin >> A >> B;

    if(A <= 5) B = 0;
    if(A >= 6 && A <= 12) B = B / 2;
    
    cout << B << endl;

    return 0;
}



Measured memory_bytes: 384
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());




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

int fre[26];
void solve(){
	int h,w;
	cin>>h>>w;
	string s;
	for(int i=0;i<h;++i){
		cin>>s;
		cout<<s<<endl;
		cout<<s<<endl;
	}
}


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


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
using namespace std;
typedef pair<int, int> pii;

int H, W;
string S[50];
int D[50][50];

int main()
{
    cin >> H >> W;
    for (int h = 0; h < H; ++h) {
        cin >> S[h];
    }
    int NumW = 0;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            D[h][w] = -1;
            if (S[h][w] == '.') ++NumW;
        }
    }

    queue<pii> Q;
    Q.push(make_pair(0, 0));
    D[0][0] = 0;
    while (!Q.empty()) {
        pii Tmp = Q.front(); Q.pop();
        int d[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

        for (int i = 0; i < 4; ++i) {
            int h = Tmp.first + d[i][0];
            int w = Tmp.second + d[i][1];
            if (h < 0 || h >= H) continue;
            if (w < 0 || w >= W) continue;
            if (S[h][w] == '#') continue;
            if (D[h][w] >= 0) continue;
            D[h][w] = D[Tmp.first][Tmp.second] + 1;
            Q.push(make_pair(h, w));
        }
    }

    if (D[H-1][W-1] == -1) cout << -1 << endl;
    else cout << NumW - D[H-1][W-1] - 1 << endl;

    return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n;
    cin1(n);
    lli a[5];
    ncin1(5, a);
    lli min_a = LLONG_MAX;
    REP(i, 0, 5) {
        if (min_a > a[i]) {
            min_a = a[i];
        }
    }
    if (n % min_a != 0)
        cout << (n / min_a + 1) +4 << endl;
    else
        cout << (n / min_a) +4 << endl;
}


Measured memory_bytes: 256
N = int(input())
dict_c = {}
for char in input():
  if char in dict_c:
    dict_c[char] += 1
  else:
    dict_c[char] = 1

for _ in range(N-1):
  word = input()
  dict_t = {}
  for char in word:
    if char in dict_t:
      dict_t[char] += 1
    else:
      dict_t[char] = 1
  for char, cnt in dict_c.items():
    if cnt != 0:
      if not char in dict_t:
        dict_c[char] = 0
      else:
        dict_c[char] = min(cnt, dict_t[char])
ans = ''
for char, cnt in sorted(dict_c.items(), key=lambda x: x[0]):
  ans += char*(cnt)
print(ans)


Measured memory_bytes: 3064
// https://atcoder.jp/contests/practice2/tasks/practice2_b
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<int> ft(N);
    REP(i, N) {
        int t;
        cin >> t;
        ft.add(i, t);
    }
    while (Q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            // 0-based index
            ft.add(u, v);
        } else {
            // 半開区間 [low, high)
            cout << ft.sum(u, v) << "\n";
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  map<int, int> cnt;
  for (int i = 0; i < 3; i++) {
  	int x;
    cin >> x;
    ++cnt[x];
  }
  for (auto i : cnt) {
  	if (i.second == 1) {
    	cout << i.first << '\n';
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		
		String s = in.nextLine();
		if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

void checkIfStaties(int A, int B) {
  int multiple = A*B;
  for(int i=A; i<=B; i++) {
    int more = i*multiple;
    if (more % 2 != 0) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
  return;
}


int main() {
  int A, B;

  cin >> A >> B;
  if( A>=1 && A<=3 && B>=1 && B<=3) {
    if(A > B) {
      checkIfStaties(B, A);
    } else {
      checkIfStaties(A, B);
    }
  }
  return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int sum = 0;
	string a, b;
	cin >> a;
	getchar();
	cin >> b;
	for (int i = 0; i < a.size(); ++i)
	{
		if (a[i] != b[i])
		{
			sum++;
		}
	}
	cout << sum << endl;
}

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

int main(void){
	char nums[10][8];
	
	strcpy(nums[0], "0111111");
	strcpy(nums[1], "0000110");
	strcpy(nums[2], "1011011");
	strcpy(nums[3], "1001111");
	strcpy(nums[4], "1100110");
	strcpy(nums[5], "1101101");
	strcpy(nums[6], "1111101");
	strcpy(nums[7], "0100111");
	strcpy(nums[8], "1111111");
	strcpy(nums[9], "1101111");

	while(1){
		int n, i, j, a;
		char ans[8];
		char now[8] = "0000000";
		
		scanf(" %d", &n);
		if(n==-1) break;
	
		for(i=0; i<n; i++){
			scanf(" %d", &a);	
			
			for(j=0; j<7; j++){
				if(now[j] == nums[a][j]) printf("0");
				else printf("1");
			}
			
			strcpy(now, nums[a]);
			
			printf("\n");
		}	
	}

	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;
 
// 并查集相关数据与算法
#define MAX_N 10000 + 16
int parent[MAX_N];
int height[MAX_N];
 
void init(const int& n)
{
	for (int i = 0; i < n; ++i)
	{
		parent[i] = i;
		height[i] = 0;
	}
}
 
int find(const int& x)
{
	if (parent[x] == x)
	{
		return x;
	}
	else
	{
		return parent[x] = find(parent[x]);
	}
}
 
void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}
 
	if (height[x] < height[y])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (height[x] == height[y])
		{
			++height[x];
		}
	}
}
 
bool same(const int& x, const int& y)
{
	return find(x) == find(y);
}
// End Of 并查集
 
#define MAX_E MAX_N * MAX_N / 2 + 1
struct edge
{
	int u, v;
	double cost;
	edge(int u = 0, int v = 0, double cost = 0) : u(u), v(v), cost(cost) {}
	bool operator < (const edge & e2) const
	{
		return cost > e2.cost;
	}
};
 
edge es[MAX_E];
int V, E;
double kruskal()
{
	sort(es, es + E);    // 按照权值从小到大排序
	init(V);
	double res = 0;
	for (int i = 0; i < E; ++i)
	{
		edge e = es[i];
		if (!same(e.u, e.v))
		{
			unite(e.u, e.v);
		}
		else
		{
			res += e.cost;
		}
	}
 
	return res;
}
 
pair<int, int> pile[MAX_N];
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	cin >> V >> E;
	
	for (int i = 0; i < V; ++i)
	{
		cin >> pile[i].first >> pile[i].second;
	}
 
	for (int i = 0; i < E; ++i)
	{
		cin >> es[i].u >> es[i].v;
		--es[i].u; --es[i].v;
		int dx = pile[es[i].u].first - pile[es[i].v].first;
		int dy = pile[es[i].u].second - pile[es[i].v].second;
		es[i].cost = sqrt(dx * dx + dy * dy);
	}
 
	cout.setf(ios::showpoint);
	cout.precision(3);
	cout.setf(ios::fixed);
	cout << kruskal() << endl;
	return 0;
}


Measured memory_bytes: 6028
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;


ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ abs(c - b) + abs(b - a),abs(c - b) + abs(c - a),abs(b - a) + abs(c - a) }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PP pop_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  priority_queue<ll, vector<ll>, less<ll>> Q;
  REP(i,n){
    ll a ;
    cin >> a ;
    Q.push(a) ;
  }
  
  ll x, y ;
  x = y = 0 ;
  
  while(SZ(Q)>=1){
    ll b, c ;
    b = Q.top() ;
    Q.pop() ;
    c = Q.top() ;
    if(b==c){
      x = b ;
      Q.pop() ;
      break ;
    }
  }
  
  while(SZ(Q)>=1){
    ll b, c ;
    b = Q.top() ;
    Q.pop() ;
    c = Q.top() ;
    if(b==c){
      y = b ;
      Q.pop() ;
      break ;
    }
  }
      
  
  
  //cout <<"x " << x <<" ; y " << y <<endl ;
  cout << x*y <<endl ;
      
    
  
  
  
  
  
  
  
  return 0 ;
}

Measured memory_bytes: 1400
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  print . showAnswer $ solve (n)

type Input  = (Int)
type Output = String

solve :: Input -> Output
solve = bool "ABD" "ABC" . (<1000)

showAnswer :: Output -> Answer
showAnswer = String

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
S=[]
H=[]
C=[]
D=[]
n=int(input())
for i in range(n):
    a,b=map(str,input().split())
    if a=='S':
        S.append(b)
    elif a=='H':
        H.append(b)
    elif a=='C':
        C.append(b)
    else:
        D.append(b)
S=list(map(int,S))
H=list(map(int,H))
C=list(map(int,C))
D=list(map(int,D))
for j in range(13):
    if not j+1 in S:
        print('S',j+1)
for k in range(13):
    if not k+1 in H:
        print('H',k+1)
for l in range(13):
    if not l+1 in C:
        print('C',l+1)
for m in range(13):
    if not m+1 in D:
        print('D',m+1)


Measured memory_bytes: 5616
//  a typical dynamic programming problem
import  java.util.*;
class Main{

    public static void main(String[] args){
    
        Scanner  s = new Scanner(System.in);
        int n = s.nextInt();
        int[][] dp  = new int[12][100001];
        int[] arr = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
        
        for(int i = 0;i < 12;i++){
            
            for(int j = 0;j < 100001;j++){
                
                if(i == 0)
                    dp[i][j] = j;
                else{
                    if(j >= arr[i])
                    dp[i][j] = Math.min(dp[i-1][j] , dp[i][j-arr[i]] + 1 );
                    else
                        dp[i][j] = dp[i-1][j];
                }
                
            }
        }
        System.out.println(dp[11][n]);
    }
}


Measured memory_bytes: 28116
n,k=map(int,input().split())
A=list(map(int,input().split()))

def culc(L):
    subL=[0]*(n+1)

    for i in range(n):
        temp=L[i]
        bottom=max(i-temp,0)
        top=min(i+temp,n-1)

        subL[bottom]+=1
        subL[top+1]-=1
    
    resL=[0]*n
    resL[0]=subL[0]
    for i in range(1,n):
        resL[i]=resL[i-1]+subL[i]

    return resL

for i in range(min(k,41)):
    A=culc(A)

print(*A)


Measured memory_bytes: 169248
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	X, t := getInt(), getInt()

	ans := X - t
	if ans < 0 {
		ans = 0
	}
	out(ans)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, ans;

int main()
{
	in >> N;
	std::vector<LL>a(N), b(N);
	rep(i, N) in >> a[i];
	rep(i, N) in >> b[i];
	rep(bit, 30)
	{
		std::vector<LL>aa(N), bb(N);
		LL mod = 1LL << bit, res = 0;
		rep(i, N)
		{
			aa[i] = a[i] % (mod << 1);
			bb[i] = b[i] % (mod << 1);
		}
		std::sort(aa.begin(), aa.end());
		std::sort(bb.begin(), bb.end());
		rep(i, N)
		{
			res += std::lower_bound(bb.begin(), bb.end(), 2 * mod - aa[i])
				- std::lower_bound(bb.begin(), bb.end(), mod - aa[i]);
			res += std::lower_bound(bb.begin(), bb.end(), 4 * mod - aa[i])
				- std::lower_bound(bb.begin(), bb.end(), 3 * mod - aa[i]);
		}
		if (res % 2 == 1) ans += mod;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 6552