akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<queue>
using namespace std;
struct edge{int to,color;};
vector<edge> w[100010];
int n,m,d[100010];
set<int> s[100010];
int main()
{
	cin>>n>>m;
	while(m--)
	{
		int a,b,c;
		cin>>a>>b>>c;
		w[a].push_back({b,c});
		w[b].push_back({a,c});
	}
	d[1]=0;
	for(int i=2;i<=n;i++)d[i]=1e6;
	priority_queue<pair<int,int>> q;
	q.push({-d[1],1});
	while(q.size())
	{
		int now=q.top().second,cost=-q.top().first;q.pop();
		if(d[now]<cost) continue;
		for(edge j:w[now])
		{
			int dist=d[now];
			if(!s[now].count(j.color)) dist++;
			if(dist<d[j.to])
			{
				d[j.to]=dist;
				s[j.to].clear();
				s[j.to].insert(j.color);
				q.push({-d[j.to],j.to});
			}
			else if(dist==d[j.to])s[j.to].insert(j.color);
		}
	}
	if(d[n]>4e5)cout<<-1<<endl;
	else cout<<d[n]<<endl;
	return 0;
}


Measured memory_bytes: 23412
import java.util.Scanner;

public class Main {

	public static double distance(double d,double plan) {

		double y,min=101.0,tmp=0.0;
		int i;
		for(i=0;i<(int)d;i++) {

			y = d-i;
			tmp = Math.sqrt(Math.pow(y, 2.0)+Math.pow(i, 2.0));
			tmp -= plan;
			tmp = Math.abs(tmp);

			if(tmp<min) {
				min = tmp;
			}

		}

		return min;
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int i;
		double d,p;

		while(true) {
			d = sc.nextDouble();
			p = sc.nextDouble();

			if(p == 0.0 && d == 0.0) break;

			System.out.printf("%.3f\n",distance(d,p));
		}

	}

}


Measured memory_bytes: 29148
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
	
int main() {
	int n;
	cin >> n;
	int b[n-1], a[n];
	rep(i,n-1) cin >> b[i];
	rep(i,n) a[i] = 0;
	rep(i,2) a[i] = b[0];
	//rep(i,n) cout << a[i] << endl;   

	rep(i,n-1) {
		//cout << i << endl;
		if (b[i] >= max(a[i],a[i+1])) {
			a[i+1] = b[i];
		} else {
			a[i] = b[i];
			a[i+1] = b[i];
		} 
	}
	

	int ans = 0;
	rep(i,n) {
		ans += a[i];
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

bool subs(char* a, char* b)
{
	int j = 0;
	for (int i = 0; a[i]; ++i) {
		while (a[i] != b[j]) {
			if (b[j] == 0) return false;
			++j;
		}
		++j;
	}
	return true;
}

int main()
{
	char S[55];
	scanf("%s", S);
	puts(subs("KIHBR", S) && subs(S, "AKIHABARA") ? "YES" : "NO");
	return 0;
}


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

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

using namespace std;

typedef long long ll;

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

  int n, m;
  cin >> n >> m;

  map<int, int> mp;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    mp[a]++; mp[b]++;
  }

  for (std::map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    int value = (*it).second;
    if (value&1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

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

int main(){
  int r,g,b,rgb;
  cin >> r >> g >> b;
  rgb = r *100 + g * 10 + b;
  if(rgb%4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

int main(){
  string S;
  cin >> S;
  vector<int> ans(S.size(), 0);
  int L_count = 0, R_count = 0;
  for (int i=0; i<S.size(); i++) {
    if (S.at(i) == 'R') R_count++;
    else if (S.at(i) == 'L') {
      ans.at(i) += R_count/2;
      ans.at(i-1) += R_count/2 + R_count%2;
      R_count = 0;
    }
  }
  for (int i=S.size()-1; i>=0; i--) {
    if (S.at(i) == 'L') L_count++;
    else if (S.at(i) == 'R') {
      ans.at(i) += L_count/2;
      ans.at(i+1) += L_count/2 + L_count%2;
      L_count = 0;
    }
  }
  for (auto answer : ans) {
    cout << answer << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (100010)


int n, m;
vector<int>e[N];
int l[N];
int r[N];
bool used[N];
int a[N];
int b[N];
bool z;

void init(void){
	memset(used, 0, sizeof(used));
	return;
}

void dfs(int x){
	used[x] = true;
	if (a[x] >= 0){
		if (a[x] < l[x] || a[x]>r[x]){
			z = false;
			return;
		}
		else if ((a[x] - l[x]) % 2 == 1){
			z = false;
			return;
		}
		l[x] = a[x];
		r[x] = a[x];
	}
	f(i, e[x].size()){
		if (!used[e[x][i]]){
			l[e[x][i]] = l[x] - 1;
			r[e[x][i]] = r[x] + 1;
			dfs(e[x][i]);
			if (!z)return;
			l[x] = max(l[x], l[e[x][i]] - 1);
			r[x] = min(r[x], r[e[x][i]] + 1);
			if (l[x] > r[x]){
				z = false;
				return;
			}
		}
	}
	return;
}

void dfsv(int x){
	used[x] = true;
	f(i, e[x].size()){
		if (!used[e[x][i]]){
			if (l[e[x][i]] <= b[x] + 1 && b[x] + 1 <= r[e[x][i]]){
				b[e[x][i]] = b[x] + 1;
				dfsv(e[x][i]);
				if (!z)return;
			}
			else if (l[e[x][i]] <= b[x] - 1 && b[x] - 1 <= r[e[x][i]]){
				b[e[x][i]] = b[x] - 1;
				dfsv(e[x][i]);
				if (!z)return;
			}
			else {
				z = false;
				return;
			}
		}
	}
}


int main(void){
	int k;
	int x, y;
	long long s, ans;
	scanf("%d", &n);
	f(i, n)a[i] = -1;
	init();
	z = true;
	f(i, n-1){
		scanf("%d %d", &x, &y);
		x--;
		y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	scanf("%d", &k);
	f(i, k){
		scanf("%d %d", &x, &y);
		x--;
		a[x] = y;
	}
	l[x] = y;
	r[x] = y;
	dfs(x);
	init();
	b[x] = l[x];
	dfsv(x);
	if (z){
		printf("Yes\n");
		f(i, n){
			printf("%d\n", b[i]);
		}
	}
	else{
		printf("No\n");
	}


	return 0;
}


Measured memory_bytes: 12672
#include<stdio.h>
int main()
{
    long a,b;
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        a=n/100;
        b=n%10;
        if(a==b)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi    = vector<int>;
constexpr int    MOD=1e9+7;

int main(){//Refering other editorials.
	int s;
	cin>>s;
	
	vi dp(s+1,0);
	dp[0]=1;
	for(int i=3;i<=s;++i) dp[i]=(dp[i-3]+dp[i-1])%MOD;
	
	cout<<dp[s]<<endl;
	return 0;
}

Measured memory_bytes: 3544
from collections import Counter
s=[i for i in input()]
t=[i for i in input()]
S=Counter(s)
T=Counter(t)
#辞書形式で返ってくるが、欲しいのはvalues、値

if sorted(S.values())==sorted(T.values()):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 7300
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

#define rep(i,M,N) for (int i = M; i < N; i++)
#define rep1(i,M,N) for (int i = M; i > N; i--)
#define getArray(a) rep(i,0,a.size()) cin >> a[i];
#define MAX(x,y) ((x)>(y)?(x):(y))

int main(){
    
    int n,t;
    while(cin>>n>>t){
        int a[n];
        rep(i,0,n) cin >> a[i];
        int max = 0;
        int min = 0;
        int min1 = 0;
        int count = 0;
        rep(i,0,n){
            if(a[i]<=a[min]){
                min = i;
            }
            if(a[i]-a[min] > max){
                min1 = min;
                count = 1;
                max = a[i]-a[min];
            }else if(a[i]-a[min] == max && min!=min1){
                count ++;
            }
            
        }
        cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  int n, a, b, max, min;
  scanf("%d",&n); scanf("%d",&a); scanf("%d",&b);
  if(a>b){
    max = b;
  }else{
    max = a;
  }
  if(a+b-n>0){
    min = a+b-n;
  }else{
    min = 0;
  }
  printf("%d %d\n", max, min);
  return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int N;
  cin >> N;
  vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  ll now = h[0];
  for (int i = 1; i < N; i++) {
    if (now < h[i]) {
      h[i]--;
      now = h[i];
    } else if (now == h[i]) {
    } else {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main(){
	int N; cin >> N;
	vector<int> button(N);
	for( int &k : button) cin >> k;
	
	int x = 1;
	for( int i = 1; i <= N; i++ ){
		x = button[x-1];
		if(x == 2){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 640
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

int main() {
  int n,k;
  int ans = 0;
  cin >> n >> k;
  while (n > 0) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
}


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

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 19;
int n, a[N];

ll f(int i, int j, int l, int r) {
	ll ans = 1e18;
	if (j - i <= 1) return 0;
	for (int d = i + 1; d < j; d++)
		ans = min(ans, f(i, d, l, l + r) + f(d, j, l + r, r) + 1ll * a[d] * (l + r));
	return ans;
}

int main() {
	rd(n), rda(a, n);
	print(f(1, n, 1, 1) + a[1] + a[n]);
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

#define SEP " "

int		main(void)
{
	int n, m;
	cin >> n >> m;
	Vec penalty(n, 0);
	vector<bool> ac(n, false);
	for (int i = 0; i < m; i++)
	{
		int p;
		string s;
		cin >> p >> s;
		if (s == "AC")
			ac[p-1] = true;
		else if (ac[p-1] == false)
			penalty[p-1]++;
	}
	int num_pen = 0;
	int num_ac = 0;

	for (int i = 0; i < n; i++)
	{
		if (ac[i])
		{
			num_pen += penalty[i];
			num_ac++;
		}
	}
	cout << num_ac << SEP << num_pen << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    int N, T;
    cin >> N >> T;
    int ans = 9999;
    int n, t;
    for (int i = 0; i < N; i++)
    {
        cin >> n >> t;
        if (t <= T && n < ans)
            ans = n;
    }
    if (ans == 9999)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int K;
    cin >> K;

    set<string> st;
    rep (i, s.size()) {
        rep (j, K+1) {
            st.insert(s.substr(i, j));
        }
    }

    auto itr = st.begin();
    rep (i, K) {
        itr++;
    }
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c)
    {
        cout << "Yes";
    }
    else if (a == c && a != b)
    {
        cout << "Yes";
    }
    else if (b == c && a != b)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        if (t > i) {
            std::cout << -1 << std::endl;
            return 0;
        }
        A.push_back(t);
    }

    int64_t count = 0;

    for (int64_t i = 0; i < N-1; ++i) {
        if (A[i+1] == 0) {
            continue;
        }

        auto d = A[i+1] - A[i];
        if (d > 1) {
            std::cout << -1 << std::endl;
            return 0;
        }
        else if (d == 1) {
            count++;
        }
        else {
            // d <= 0
            count += A[i+1];
        }
    }


    std::cout << count << std::endl;

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


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

int main2() {
  int N = nextInt();
  int M = nextInt();
  vector<int> a(N);
  REP(i, N) a[i] = nextInt();
  int S = accumulate(ALL(a), 0);
  int m = 0;
  REP(i, N) {
    if (a[i] >= (S + 4*M-1)/(4*M))
      m++;
  }
  if (m >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	int total=0;
	double sum;
	int a[101]={0};
	cin>>n>>m;	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sum/=(4*m);
	for(int i=1;i<=n;i++){
		if(a[i]>=sum){
			total++;
		}
	}
	if(total>=m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int calc(int n){
  int sum = 0;
  while(n!=0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  if(n%calc(n)==0){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  int a[n];
  int x = 0;
  REP(i,n){
    cin>>a[i];
    x ^= a[i];
  }
  int bit[n] = {};
  REP(i,n){
    int target = a[i] ^ (a[i] - 1);
    int temp = 1;
    int res = 0;
    REPP(k,30){
      //temp *= 2;
      if(temp<=target){
        res++;
      }else{
        break;
      }
      temp *= 2;
    }
    bit[i] = res - 1;
  }
  for(int k = 29; k>=0; k--){
    if((x>>k) & 1){
      bool flag = false;
      REP(i,n){
        if(bit[i] == k){
          flag = true;
          x ^= a[i] ^ (a[i] - 1);
          bit[i] = -1;
          break;
        }
      }
      if(!flag){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  int ans = 0;
  if(x == 0){
    REP(i,n){
      if(bit[i] == -1){
        ans++;
      }
    }
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
    
    
      
  return 0; 
}


Measured memory_bytes: 1152
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int const N = 1e5 + 5;
const int INF = 1e15;

int32_t main(){
    int n, W;
    cin >> n >> W;
    
    vector<int> dp(100001, INF);
    dp[0] = 0;
    
    for(int i = 0; i < n; i++){
        int w, v;
        cin >> w >> v;
        
        for(int i = 100000 - v; i >= 0; i--){
            dp[i + v] = min(dp[i + v], dp[i] + w);
        }
    }
    
    int res = 0;
    for(int i = 1; i <= 100000; i++){
        if(dp[i] <= W)
            res = max(res, i);
    }
    cout << res << endl;
}




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

int N, M, K;
int stac[110][110], stat[110][110];
static const int INF = 100000000;

int main() {
	for(;;) {
		cin >> N >> M;
		if(!N && !M) {
			break;
		}
		for(int i = 0; i < 110; i++) {
			for(int j = 0; j < 110; j++) {
				stac[i][j] = stat[i][j] = INF;
			}
		}

		for(int i = 0; i < N; i++) {
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			stac[a][b] = stac[b][a] = cost;
			stat[a][b] = stat[b][a] = time;
		}

		for(int k = 1; k <= M; k++) {
			for(int i = 1; i <= M; i++) {
				for(int j = 1; j <= M; j++) {
					stac[i][j] = min(stac[i][j], stac[i][k] + stac[k][j]);
					stat[i][j] = min(stat[i][j], stat[i][k] + stat[k][j]);
				}
			}
		}

		cin >> K;
		for(int i = 0; i < K; i++) {
			int p, q, r;
			cin >> p >> q >> r;
			if(!r) {
				cout << stac[p][q] << endl;
			} else {
				cout << stat[p][q] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 956
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

void show (set<int> st) {
    for (auto e: st) cout << e << " ";
    cout << endl;
}

int main(void) {
    string s;
    int tx, ty;
    cin >> s >> tx >> ty;
    s += "T";
    int n = s.length();
    
    set<int> x {0},  y {0};
    bool x_coord = true;
    bool is_first = true;
    
    int cnt = 0;
    repeat(i, n) {
        //dump(i); dump(cnt); el;
        if (s[i] == 'F') {
            ++cnt;
        }
        else {
            set<int> & st = (x_coord ? x : y);
            set<int> nst;
            for (auto e : st) {
                if (is_first) {
                    nst.insert(cnt);
                    is_first = false;
                }
                else {
                    nst.insert(e + cnt);
                    nst.insert(e - cnt);
                }
            }
            cnt = 0;
            x_coord = !x_coord;
            st = move(nst);
            //cout << "x" << endl; show(x); cout << endl;
            //cout << "y" << endl; show(y); cout << endl;
        }
    }
    
    if (x.find(tx) != x.end() && y.find(ty) != y.end()) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
        
}

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

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

    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    S.insert(S.begin(), '\0');
    vector<int> cs(N+1);
    for (int i = 1; i <= N; i++) {
        if (S[i-1] == 'A' && S[i] == 'C') cs[i] = 1;
        cs[i] += cs[i-1];
    }
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        cout << cs[r] - cs[l] << "\n";
    }
}

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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	sort(s.begin(), s.end());
	if (s=="abc")
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  int count[100] = {0};
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    count[(char)s[i]-97]++;
  }
  for(int i = 0; i < 100; i++){
    if(count[i]%2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 1;
const int N=1e5;
int far[maxn],Rank[maxn],X[N],Y[N];
int n,m;
set<int> x[maxn],y[maxn];
int find(int x)
{
    if(far[x] == x)return x;
    else return far[x] = find(far[x]);
}
void unite(int x,int y)
{
    x = find(x);
    y = find(y);
    if(x == y)return;
    //far[y] = x;
    if(Rank[x] > Rank[y]) far[y] = x;
    else
    {
        far[x] = y;
        if(Rank[y] == Rank[x]) Rank[y]++;
    }
    //cout<<far[x]<<" "<<far[y]<<endl; 
}
void init(int n)
{
    for(int i = 0;i < n;i++)
    {
        far[i] = i;
        Rank[i] = 0;
    }
}
int main()
{
	//cout<<1<<endl;
	int n;cin>>n;
	init(maxn);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&X[i],&Y[i]);
		X[i]--,Y[i]--;
		//cout<<X[i]<<" "<<Y[i]<<" "<<far[100000]<<endl;
		unite(i,N+X[i]);unite(i,2*N+Y[i]);
	}
	for(int i=0;i<n;i++)
	{
		x[find(i)].emplace(X[i]);
		y[find(i)].emplace(Y[i]);
	}
	ll ans = -n;
	for(int i=0;i<maxn;i++)
	{
		int tmp1=x[i].size(),tmp2=y[i].size();
		ans+=1ll*tmp1*tmp2;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 36224
#include <iostream>

using namespace std;

int main(){
  int n, b, f, r, v, room[4][3][10] = {};

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

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

  return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vl;
typedef vector<vl> vv;
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define endl '\n'
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }

vv gph(1e5+5);
vl dp(1e5+5);
vl vst(1e5+5);
ll maxi=-1;

void dfs(ll x){

    vst[x]=1;

    for(ll i=0;i<gph[x].size();i++){

        if(!vst[gph[x][i]]){dfs(gph[x][i]);}
        dp[x]=max(dp[x],1+dp[gph[x][i]]);
        maxi=max(maxi,dp[x]);
    }

}

int main(){
    
    fast();
    //#ifndef ONLINE_JUDGE
    //freopen("F:\\Codes\\input.txt", "r", stdin);
    //freopen("F:\\Codes\\output.txt", "w", stdout);
   // #endif
    
    ll n,m,a,b,i;
    cin>>n>>m;

    while(m--){
        cin>>a>>b;
        gph[a].pb(b);
    }

    for(i=1;i<=n;i++){
        if(!vst[i]){
            dfs(i);
        }
    }
    cout<<maxi<<endl;



    
    return 0;
}

Measured memory_bytes: 12052
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

int dp[1010][1010] = {0};

int lcs(string x, string y){
    int n = x.size();
    int m = y.size();
    int ans = 0;
    for(int i=1; i<n+1; i++){
        for(int j=1; j<m+1; j++){
            if(y[j-1] == x[i-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            ans = max(ans, dp[i][j]);
        }
    }
    return ans;

}

int main(){
    int q;
    cin >> q;
    rep(i, q){
        string x,y;
        cin >> x >> y;
        cout << lcs(x,y) << endl;
    }
}



Measured memory_bytes: 7168
// AtCoder Beginner Contest 170 C.cpp

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int x, n, temp;
	int dp[102] = { 0, };
	cin >> x >> n;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		dp[temp]++;
	}
	for (int i = 0;; i++) {
		if (dp[x - i] == 0) {
			cout << x - i << endl;
			break;
		}
		if (dp[x + i] == 0) {
			cout << x + i << endl;
			break;
		}
	}
}

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

int main(){
int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(C<1){
     cout << "Yes" <<endl;
      break;
    }
    A -= D;
    if(A<1){
     cout << "No" <<endl;
      break;
    }
  }
}

Measured memory_bytes: 3596
S = input()
additions = [[],[]]
direction = 0
Q = int(input())
for _ in range(Q):
    query = input().split()
    T = int(query[0])
    if T == 1:
        direction ^= 1
    else:
        F = int(query[1])
        C = query[2]
        additions[(F+direction+1) % 2].append(C)
if direction == 0:
    print(''.join(additions[0][::-1]), end='')
    print(S, end='')
    print(''.join(additions[1]))
else:
    print(''.join(additions[1][::-1]), end='')
    print(S[::-1], end='')
    print(''.join(additions[0]))

Measured memory_bytes: 69848
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long C = gcd(A, B);
    
    int ans = 1;
    long N = (long)Math.sqrt(C);
    for(int i = 2; i <= N+1; i++){
      if(C%i == 0){
        ans++;
        while(C%i == 0){
          C /= i;
        }
      }
    }
    if(C > 1){
      ans++;
    }
    System.out.println(ans);
  }
  public static long gcd(long A, long B){
    if(A < B){
      return gcd(B, A);
    }
    
    if(B == 0){
      return A;
    }
    
    return gcd(B, A%B);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
      string s;
      cin >> s;
      int ans = (int) 1e9;
      for (char c = 'a'; c <= 'z'; c++) {
        string w = s;
        for (int it = 0; ; it++) {
          if (w.empty()) {
            break;
          }
         
          if (w == string(w.length(), c)) {
            ans = min(ans, it);
            break;
          }
          string nw = "";
          for (int i = 0; i < (int) w.size() - 1; i++) {
            if (w[i] == c || w[i + 1] == c) {
              nw += c;
            } else {
              nw += w[i];
            }
          }
          w = nw;
        }
      }
      printf("%d\n", ans);
      return 0;
    }

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

using namespace std;

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int limit = max(X, Y) * 2;
  long long int budget = 1000000000;
  for(int c = 0; c <= limit; c+=2){
    long long int tmp = max(A * (X - c/2),0) + max(B * (Y - c/2),0) + c * C;
    budget = min(budget,tmp);
  }
  cout << budget;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int a,b = 0;

	scanf("%d %d",&a,&b);

	if((a > 0 && a <=9) && (b > 0 && b <=9)){

	printf("%d",a*b);

	}else{

	printf("%d",-1);
	}


	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int saiki(int,int,int,int);
int n,s,cnt=0;
int main(){
	while(1){
		cin>>n>>s;
		if(n==0&&s==0)break;
		saiki(0,0,-1,10);
		cout<<cnt<<endl;
		cnt=0;
	}
	return 0;
}
int saiki(int i,int sum,int mae,int last){
	if(i==n)return sum;
	for(int j=mae+1;j<=(last<=9?last:9);++j){
		if(saiki(i+1,sum+j,j,s-(sum+j))==s)cnt++;
	}
	return -1;
}


Measured memory_bytes: 3080
#include<stdio.h>
char *P[]={"Yes", "No"};
char f;
short n;
int main(){
  scanf("%hd", &n);
  switch(n){
    case 1: case 2: case 3: case 5: case 6: case 9: case 10: case 13: case 17:
      f=1;
  }
  puts(P[f]);
}


Measured memory_bytes: 128
$n=<>;$h[$|--]{$_}--for glob<>;
($u,$x,$v,$y)=map$h[$i++/2]{$_},@a=map{(sort{$$_{$a}-$$_{$b}}keys%$_)[0,1]}@h;
print$n+("@a"-$a[2]?$u+$v:($u+=$y)-($-=$u-$v-$x))

Measured memory_bytes: 30208
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int n;
  cin >> n;
  int ans[200010];
  REP(i, n) { ans[i] = 0; }
  REP(i, n - 1) {
    int t;
    cin >> t;
    ans[t - 1] += 1;
  }

  REP(i, n) { cout << ans[i] << endl; }

  return 0;
};


Measured memory_bytes: 5172
import bisect


def solve(mid):
    cnt = 0
    l = n
    r = n
    for i in range(n):
        while True:
            if l == 0:
                break
            if a[l - 1] < mid - a[i]:
                break
            l -= 1
        cnt += (r - l)
    return cnt >= m
    

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

ok = 0
ng = 2 * 10 ** 5 + 10
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

ru = [0] * (n + 1)
for i in range(n):
    ru[i + 1] = ru[i] + a[i]

ans = 0
r = n
ok = ok + 1
cnt = 0
for i in range(n):
    l = bisect.bisect_left(a, ok - a[i])
    cnt += (r - l)
    ans += (r - l) * a[i] + (ru[r] - ru[l])
ans += (ok - 1) * (m - cnt)
print(ans)


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int M = Integer.parseInt(st.nextToken());
		int[] arr = new int[N];
		st = new StringTokenizer(br.readLine());
		int sum = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			sum += arr[i];
		}
		double val = ((double) sum) / (4.0 * (double) M);
		int count = 0;
		for (int i = 0; i < N; i++) {
			if (arr[i] >= val) {
				count++;
			}
		}
		System.out.println(count < M ? "No" : "Yes");
	}
}

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

const int MOD = 1e9+7;
int add(int a, int b){return ((ll)a + (ll)b)%MOD;}
int mul(int a, int b){return ((ll)a * (ll)b)%MOD;}

void solve(){
  int s, w;
  cin >> s >> w;
  cout << (w >= s ? "unsafe" : "safe") << '\n';
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int sl = s.length();
    ll ans = 0;
    
    for (int i = 0; i < (1 << (sl - 1)); i++) {
        bitset<9> b(i);
        ll tmp = 0;
        ll stack = 0;
        
        for (int ii = 0; ii < sl; ii++) {
            stack = stack * 10 + (s[ii] - '0');
            
            if (b[ii]) {
                tmp += stack;
                stack = 0;
            }
        }
        
        tmp += stack;
        ans += tmp;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int X = in.nextInt(), Y = in.nextInt(), n = in.nextInt();
        int[] x = new int[n], y  = new int[n], a = new int[n];
        for(int i = 0; i < n; i++){
            x[i] = in.nextInt();
            y[i] = in.nextInt();
            a[i] = in.nextInt();
        }
        int mx = 0, my = 0;
        for(int i = 0; i < n; i++){
            switch(a[i]){
            case 1: mx = Math.max(mx, x[i]); break;
            case 2:  X = Math.min( X, x[i]); break;
            case 3: my = Math.max(my, y[i]); break;
            case 4:  Y = Math.min( Y, y[i]); break;
            }
        }
        System.out.println(Math.max(0, (X - mx)) * Math.max(0, (Y - my)));
    }
}

Measured memory_bytes: 24020
#include <stdio.h>
 
int main(void) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    
    int x = x2-x1, y = y2-y1;
    int x3, y3, x4, y4;
    x3 = x2 - y;
    y3 = y2 + x;
    x4 = x1 - y;
    y4 = y1 + x;

    printf("%d %d %d %d\n", x3, y3, x4, y4 );
    
    return 0;
}   

Measured memory_bytes: 128
H,W,K =map(int,input().split()) 
L = [list(input()) for i in range(H)]
ans = 0
for h in range(1<<H):
    for w in range(1<<W):
        cnt = 0
        for j in range(H):
            for i in range(W):
                if h>>j&1 == 0 and w>>i&1 == 0:
                    if L[j][i] == "#":
                        cnt +=1
        if cnt == K:
            ans +=1
print(ans)

Measured memory_bytes: 9116
num = gets.chomp.to_i
remenber = 1

# n乗の探索
i = 2
loop do

    if 2 ** i > num
        puts remenber
        break
    end

    j = 2
    loop do
        if (j**i) > num
            #print j-1,"**",i,"=",(j-1)**i,"\n"

            if remenber < (j-1)**i
                remenber = (j-1)**i
            end
            break
        end

        j += 1
    end
 
    i += 1
end

Measured memory_bytes: 1788
# https://atcoder.jp/contests/abc054/tasks/abc054_a



A, B = gets.split.map(&:to_i)

ans = if A == B
        'Draw'
      elsif A > B
        B == 1 ? 'Bob' : 'Alice'
      else
        A == 1 ? 'Alice' : 'Bob'
      end

puts ans


Measured memory_bytes: 1788
import numpy as np

n,m,x=map(int, input().split())
sl=[]
pl=[]
for k in range(n):
  book=list(map(int,input().split()))
  sl.append(book[1:])
  pl.append(book[0])
  
sl=np.array(sl)
ans=10**8

for i in range(2**n):
  skill=np.zeros(m)
  price=0
  for j in range (n):
    if ((i>>j)&1):
      skill+=sl[j]
      price+=pl[j]
  bottom=np.amin(skill)
  if bottom>=x and price<ans:
    ans=price
if ans==10**8:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 26956
#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define u_map                 unordered_map<ll,ll>
#define n_map                 map<ll,ll>
#define n_pair                pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define frr(i,j,k)           for(int i=j; i<k; i++)
#define frp(i,j,k)           for(int i=j; i>=k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define in(t)                 scanf("%lld",&t);
#define out(t)                printf("%lld\n",t);
#define inputarr(a,n)        for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n)        for(int i=0;i<n;++i) cout<<a[i]<<" "
#define mem(a)              memset(a,0,sizeof(a))
#define int_max     INT_MAX64
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
ll ans=0;
int main(){
    ll n,k;
    cin>>n;
    ll v[n][3];
    frr(i,0,n){
        frr(j,0,3){
            cin>>v[i][j];
        }
    }
    ll a[n+1],b[n+1],c[n+1];
    frr(i,0,n){
        a[i]=v[i][0];
    }
    frr(i,0,n){
        b[i]=v[i][1];
    }
    frr(i,0,n){
        c[i]=v[i][2];
    }
    ll dp[n+1][3];
    mem(dp);
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    //cout<<c[0]<<endl;
    for(int i=1;i<n;++i){
       dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
       dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
       dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextInt();
        final char[] array = scanner.next().toCharArray();

        int leftCount = 0;
        int rightCount = 0;
        for (final char c : array) {
            if (c == ')') {
                if (leftCount > 0) {
                    leftCount--;
                } else {
                    rightCount++;
                }
            } else {
                leftCount++;
            }
        }

        for (int i = 0; i < rightCount; i++) {
            System.out.print('(');
        }
        for (final char c : array) {
            System.out.print(c);
        }
        for (int i = 0; i < leftCount; i++) {
            System.out.print(')');
        }
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

ll a[100010],b[100010];
int main(){
	ll T;
	scanf("%lld",&T);
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld%lld",a+i,b+i);
	int r=0;
	ll time=0,ans=0;
	rep(l,0,n){
		while(r<n&&b[r]-a[l]<T)time+=b[r]-a[r],r++;
		ll temp=r<n?max(0,T-(a[r]-a[l])):0;
		ans=max(ans,time+temp);
		time-=b[l]-a[l];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a;
    string b;
    cin >> a >> b;
    string d = b.substr(0, 1) + b.substr(2, 1) + b.substr(3, 1);
    ll e = stoll(d);
    ll c = a * e;
    cout << c / 100 << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  double t, x;
  cin >> t >> x;
  printf("%.10f\n", t / x);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef modint998244353 mi;
const int N = 2e5 + 87;
const mi inv9 = mi(1) / mi(9);
struct S
{
    mi su;
    mi pw;
};
S op(S a, S b)
{
    return {a.su * b.pw + b.su, a.pw * b.pw};
}
S e()
{
    return {0, 1};
}
struct F
{
    mi v;
};
S mapping(F f, S x)
{
    if  (f.v == 10)
        return x;
    x.su = (x.pw - 1) * inv9 * f.v;
    return x;
}
F id()
{
    return {10};
}
F composition(F f, F g)
{
    if (f.v == 10)
        return g;
    return f;
}
int main()
{
    int n, q;
    cin >> n >> q;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
    for (int i = 0; i < n; ++i)
        seg.set(i, {1, 10});
    cerr << seg.all_prod().su.val() << '\n';
    /*
    seg.set(7,0);
    cerr << seg.all_prod().val() << '\n';
    exit(0);*/
    for (int i = 0; i < q; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        seg.apply(l, r, F{d});
        cout << seg.all_prod().su.val() << '\n';
    }
}


Measured memory_bytes: 9896