akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
lld arr[222222];
int main(void){
	int n;
	lld k;
	scanf("%d%lld",&n,&k);
	for(int e=0;e<n;e++) scanf("%lld",&arr[e]);
	lld ll = 1,rr = 1e9,mid,ans = 1e9 + 100;
	while(ll<=rr){
		mid = (ll+rr)/2;
		lld now = 0;
		for(int p=0;p<n;p++) {
			lld kk = (arr[p]/mid);
			if(arr[p]%mid) kk++;
			now += (kk-1);
		}
		if(now<=k){
			ans = min(ans,mid);
			rr = mid - 1;
		}else ll = mid + 1;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 5380
#include <cmath>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    double x=0,y=0,met,theta,thetas=0,pi=3.1415926535897;
    while(1){
        scanf("%lf,%lf",&met,&theta);
        if(met==0&&theta==0) break;
        x+=met*sin(thetas*pi/180.0);
        y+=met*cos(thetas*pi/180.0);
        thetas+=theta;
    }
    printf("%d\n%d\n",(int)(floor(fabs(x))*x/fabs(x)),(int)(floor(fabs(y))*y/fabs(y)));
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;


void solve(){
    int N;
    cin >> N;
    vector<ll> a(N);
    bool zero = false;
    REP(i,N){
        cin >> a[i];
        if(a[i] == 0) zero = true;
    }
    if(zero){
        cout << 0 << endl;
        return;
    }
    ll ans = 1;
    REP(i,N){
        if(ans > LINF / a[i]){
            cout << -1 << endl;
            return;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3988
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    string s;
    cin >> s;
    reverse(All(s));
    for (int i = 2; i < s.length(); i += 2)
    {
        string t = s.substr(i);
        int l = t.length();
        if (t.substr(0,l / 2) == t.substr(l/2))
        {
            cout << l << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    int n,m;cin>>n>>m;
    int h[n];
    rep(i,n) cin>>h[i];
    map<pint,int> mp;
    int a[m],b[m];
    rep(i,m) cin>>a[i]>>b[i];
    rep(i,m) {
        int aa=a[i],bb=b[i];
        int a=max(aa,bb);
        int b=min(aa,bb);
        mp[{a,b}]++;
        //cout<<a<<" "<<b<<"\n";
        //mp[b[i]]=a[i];
    }

    Graph hm(n);
    for(auto p:mp){
        int a,b;
        tie(a,b)=p.first;
        hm[a-1].push_back(h[b-1]);
        hm[b-1].push_back(h[a-1]);
    }
    //for(auto p:mp) cout<<p.first.first<<" "<<p.first.second<<"\n";
    /*rep(i,m){
        hm[a[i]-1].push_back(h[b[i]-1]);
        hm[b[i]-1].push_back(h[a[i]-1]);
    }*/
    int cnt=0;
    rep(i,n){
        int k=hm[i].size();
        bool chk=1;
        //cout<<k<<"\n";
        rep(j,k){
            if(h[i]<=hm[i][j]){
                chk=0;
               // cout<<i+1<<"\n";
                break;
            }
        }
        if(chk) cnt++;
    }

    cout<<cnt<<"\n";
}

Measured memory_bytes: 15920
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,a,b,i;
    cin>>n;
    vector<pair<pair<int,int>,int>> pts;
    for (i=0;i<n;i++)
    {
        cin>>a>>b;
        pts.pb(mp(mp(a,b),0));
    }
    for (i=0;i<n;i++)
    {
        cin>>a>>b;
        pts.pb(mp(mp(a,b),1));
    }
    sort(pts.begin(),pts.end());
    set<pair<int,int>> s;
    int ans=0,mark[2*n]={0};
    for (i=0;i<2*n;i++)
    {
        if (pts[i].ss==0)
            s.insert(mp(pts[i].ff.ss,i));
        else
        {
            int choose=-1;
            for (auto e: s)
            {
                if (e.ff<pts[i].ff.ss && mark[e.ss]==0)
                    choose=e.ss;
            }
            if (choose!=-1)
            {
                ans++;
                mark[i]=1;
                mark[choose]=1;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

const ll x = 100000;
int main(){
  ll n, q;
  cin >> n;
  vector<ll> a(x+1, 0);
  ll sum = 0;
  rep(i, n){
    ll num;
    cin >> num;
    a[num]++;
    sum += num;
  }
  cin >> q;
  rep(i, q){
    ll b, c;
    cin >> b >> c;
    sum -= a[b] * b;
    sum += a[b] * c;
    a[c] += a[b];
    a[b] = 0;
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4048
#include<stdio.h>
using namespace std;

int main(){
    char array[2001];
    int m,n,tmp;
    while(1){
        scanf("%s",array);
        if(array[0]=='-') break;
        tmp=0;
        for(int i=0; array[i]!='\0'; i++) tmp++;
        scanf("%d",&m);
        int a=0;
        for(int i=0; i<m; i++){
            scanf("%d",&n);
            for(int j=0; j<n; j++){
                array[a+tmp]=array[a];
                a++;
            }
        }
        for(int i=0; i<tmp; i++){
            printf("%c",array[a+i]);
        }
        printf("\n");
    }
}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
using namespace std;
const int maxx = 100010;
const int INF = 1 << 30;

vector<int>G[maxx];
list<int>out;
bool flag[maxx];
int n;

void dfs(int u) {
	flag[u] = true;

	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		if (flag[v] == 0)
			dfs(v);
	}
	out.push_front(u);
}

void tsort() {
	for (int i = 0; i < n; i++) {
		flag[i] = false;
	}

	for (int u = 0; u < n; u++) {
		if ( flag[u] == 0)
			dfs(u);
	}

	for (list<int>::iterator it = out.begin(); it != out.end(); it++)
		printf("%d\n", *it);
}
int main()
{
	int s, t, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &s, &t);
		G[s].push_back(t);
	}

	tsort();
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin >> a >> b;
    if(a>b){
        cout << '>' << endl;
    }else if(a<b){
        cout << '<' << endl;
    }else{
        cout << '=' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long double x,d,ans;
int n;
int main(){
	scanf("%d%Lf%Lf",&n,&x,&d);
	for(int i=1;i<=n;i++){
		int tot=2*(n-i+1);
		ans+=(x*2+(tot-1)*d)/2;
		x+=(x*2+5*d)/tot;
		d+=4*d/tot;
	}
	printf("%.9Lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <math.h>
using namespace std;


int main(){
    int i,j,k,x,yakusuu;
    cin>>x;
    i=x;
    i=i-1;
	while(1){
        
        i++;
		yakusuu=0;
		for(j=1;j<=i;j++)
		{
			if(i%j==0) yakusuu++;
		}

		if(yakusuu==2) break;
	}
    
    cout<<i<<endl;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n / 2; i++){
        if (s[i] != s[n-1-i]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int cnt; int N, Ans;

void choose(int k, int l, int digit) {
  if(l == N && k == Ans) { cnt++; return; }
  else if (l == N) return;
  else if (digit >= 10) return;
  
  choose(k+digit, l+1, digit+1);
  choose(k, l, digit+1);
}

int main () {
  while(cin>>N>>Ans) {
    if(N == 0 && Ans == 0) break;
    cnt = 0;
    choose(0, 0, 0);
    cout << cnt << endl;
  }
  return 0;
}

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

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A,B;
    cin >> A >> B;
    ll ans = 0;
    if ( A >= 13 ) ans = B;
    else if (A >= 6) ans = B/2;
    else ans = 0;
    cout << ans << '\n';
    return 0;
}

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

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var quite = N / 2;
            var remain = N % 2;

            Console.WriteLine(quite + remain);


        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main() {
  int n,sum = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 1; i < n-1; i++){
    if ((a[i] < a[i-1] && a[i] > a[i+1]) || (a[i] > a[i-1] && a[i] < a[i+1]) /*つまり、つまりよ。ってことは、「二番目か否か」っていうことじゃねぇ～の？（笑笑）*/){
      sum++;
    }
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3632
n,k = map(int, input().split())
al = list(map(int, input().split()))
fl = list(map(int, input().split()))

al.sort()
fl.sort(reverse=True)
afl = []
for a,f in zip(al,fl):
    afl.append((a,f))

ok, ng = 10**12, -1
while abs(ok-ng) > 1:
    mid = (ok+ng) // 2
    cnt = 0
    for a,f in afl:
        val = a*f
        train_cnt = (val-mid-1)//f + 1
        cnt += max(train_cnt, 0)

    if cnt <= k:
        ok = mid
    else:
    	ng = mid
print(ok)

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

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

    int n;
    cin >> n;
    bool even = true;
    rep(i,n){
        ll a;
        cin >> a;
        if(a%2)
            even = false;
    }
    if(even)
        cout << "second" << endl;
    else
        cout << "first" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int h,w,k; cin>>h>>w>>k;
    vector<string> s(h);
    rep(i,h) cin>>s[i];

    int x = h+w;
    auto calc = [&](const vector<int> &a) -> int {
        vector<string> t(s);
        vector<int> tate, yoko;
        for (auto &&e: a) {
            if (e < h) tate.push_back(e);
            else yoko.push_back(e-h);
        }
        for (auto &&e: tate) {
            rep(j,w) {
                t[e][j] = '$';
            }
        }
        for (auto &&e: yoko) {
            rep(i,h) {
                t[i][e] = '$';
            }
        }
        int res = 0;
        rep(i,h) rep(j,w) if (t[i][j] == '#') res++;
        return res;
    };

    int ans = 0;
    for (int bit = 0; bit < (1<<x); ++bit) {
        vector<int> a;
        rep(i,x) {
            if (bit & (1<<i)) a.push_back(i);
        }

        if (calc(a) == k) ans++;
    }

    cout << ans << '\n';

    return 0;
}

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

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

		A = A - D;
		if(A <= 0){
			cout << "No" << endl;
			break;
		}
	}
}


Measured memory_bytes: 3596
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

 
    cin >> N;
    cin >> M;
    cin >> K;
    A.push_back(N);
    A.push_back(M);
    A.push_back(K);

    sort(A.begin(),A.end());
    cout << A[0]+A[1] << endl;
    

}

Measured memory_bytes: 3608
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer a = Integer.parseInt(scanner.next());

        Integer[] b = new Integer[a];
        for(int i = 0; i < a; i++) {
            b[i] = Integer.parseInt(scanner.next());
        }

        double sum = Stream.of(b).mapToInt(Integer::intValue).sum();
        sum = Math.round(sum/a);

        Long total  = 0L;
        for(int i = 0; i < b.length; i++) {
            total += (b[i] - (long)sum) * (b[i] - (long)sum);
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 28112
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <functional>

#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int findIndex( int value, vector<int> v ){
    auto iter = find( v.begin(), v.end(), value);
    size_t index = distance( v.begin(), iter );
    if(index == v.size()){
        return -1;
    }
    return index;
}

int main(){
    int N=0;
    int p=0,q=0;
    cin >> N;
    vector<int> P(N+5,0);
    vector<int> Q(N+5,0);
    vector<int> v,V(N,0);
    for (int i = 0; i < N; i++){
        cin >> P[i];
        p += pow(10,N-i-1) * P[i];
        V[i] = i+1;
    }
    for (int i = 0; i < N; i++){
        cin >> Q[i];
        q += pow(10,N-i-1) * Q[i];
    }

    int tmp=0;
    do {
    for (int i = 0; i < V.size(); i++) {
      tmp += pow(10,N-i-1) *  V[i];
    }
    v.push_back(tmp);
    tmp=0;
    } while (next_permutation(V.begin(), V.end()));

    sort(v.begin(),v.end());
    int result_p = findIndex(p,v);
    int result_q = findIndex(q,v);
    
    // cout << p << q << endl;
    // for(int i= 0; i< v.size();i++){
    //     cout << v[i] <<endl;
    // }
    // cout << result_p << endl;
    cout << abs(result_p - result_q) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct UnionFind{
  VI par,sizes; // par[i]:iの親の番号
  UnionFind(int n) : par(n), sizes(n,1){ // 最初は全てが根であるとして初期化
    rep(i,n) par[i] = i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y){
    int rx = root(x); int ry = root(y);
    if(rx==ry) return;
    if(sizes[rx]<sizes[ry]) swap(rx,ry);
    par[ry] = rx;
    sizes[rx] += sizes[ry];
  }
  bool same(int x, int y){
    return root(x)==root(y);
  }
  int size(int x){
    return sizes[root(x)];
  }
};

signed main(){
  int n,m; cin>>n>>m;
  int w[n]; bool r[n];
  rep(i,n){
    w[i]=1; r[i]=false;
  }
  r[0]=true;
  rep(i,m){
    int x,y; cin>>x>>y; x--; y--;
    if(r[x]&&w[x]) r[y]=true;
    w[x]--; w[y]++;
    if(w[x]==0) r[x]=false;
  }
  int ans = 0;
  rep(i,n) if(r[i]) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 5e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int fac[2500], finv[2500], inv[2500];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2500; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int gcd(int X,int Y) {
    if(X%Y == 0) {
        return Y;
    }
    else {
        return gcd(Y,X%Y);
    }
}
signed main() {
    int N,K;
    cin >> N >> K;
    vector<P>x(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i].first >> x[i].second;
    }
    sort(x.begin(),x.end());
    int ans = INF;
    for(int i = 0; i < N; i++) {
        for(int j = i; j < N; j++) {
            if(j-i+1 < K) {
                continue;
            }
            int res = x[j].first-x[i].first;
            vector<int>cnt;
            for(int k = i; k <= j; k++) {
                cnt.push_back(x[k].second);
            }
            sort(cnt.begin(),cnt.end());
            for(int k = 0; k <= j-i+1-K; k++) {
                int cnt2 = j-i+1-K-k;
                ans = min(ans,res*(cnt[cnt.size()-1-cnt2]-cnt[k]));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
#define int long long
using namespace std;
signed main() {
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    char s[5050]; int n;
    scanf("%d", &n);
    scanf("%s", s);
    int max = 0;
    forn(i, n) {
        int t = 0;
        forn(j, n - i) {
            t = (t + 1) * (s[j] == s[j + i]);
            uax(max, min(i, t));
        }
    }
    printf("%d", max);

}

Measured memory_bytes: 256
#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 << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
a,b,c=map(eval,input().split())
lar=[[]for i in range(a)]
for j in range(a):
    start=input()
    for q in range(len(start)):
        lar[j]+=[start[q]]
kok=0
for i in range(a):
    for j in range(b):
        if lar[i][j]=="#":
            kok+=1
w=0
num2=(2**a)*(2**b)
for i in range(num2):
    pop=[[0 for i in range(b+5)]for j in range(a+5)]
    num=0
    p=bin(i)[2:]
    e=p[::-1]
    for q in range(len(e)):
        if q-a<=-1 and e[q]=="1":
            for m in range(b):
                pop[q][m]=1
        if q-a>-1 and e[q]=="1":
            for j in range(a):
                pop[j][q-a]=1
    for i in range(a):
        for j in range(b):
            if lar[i][j]=="#" and pop[i][j]==0:
                num+=1
    if num==c:
        w+=1
print(w)

Measured memory_bytes: 9188
S = int(input())

MOD = 10**9 + 7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

maxN = S // 3
minN = S // 9 + 1
k = S % 3

N = 4000
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

ans = 0
for n in range(maxN, 0, -1):
    ans = (ans + cmb(n+k-1,k,MOD)) % MOD
    k += 3

print(ans)
    

Measured memory_bytes: 65964
///-BISMILLAHIR RAHMANIR RAHIM-///
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define pb push_back
#define scn(n) scanf("%lld",&n)
#define pi acos(-1)
#define ll long long
#define llu unsigned long long
#define mod 1000000007
int main()
{
    ll n,q;
    cin>>n>>q;
    vector<ll>v[n+1];
    ll p,t,x;
    while(q--)
    {
        cin>>p;
        if(p==0)
        {
            cin>>t>>x;
            v[t].push_back(x);
        }
        else if(p==1)
        {
            cin>>t;
            ll i,len;
            len=v[t].size();
            if(len==0)
                cout<<endl;
            else
            {
                for(i=0;i<len; i++)
                {
                    cout<<v[t][i];
                    if(i!=len-1) cout<<" ";
                }
                cout<<endl;
            }
        }
        else
        {
            cin>>t;
            if(!v[t].empty())
            {
                v[t].clear();
            }
        }
    }
    return 0;
}



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

using namespace std;

typedef long long ll;

class union_find {
    vector<long long> par, sz, h;

public:
     union_find(long long n) {
        par.resize(n);
        h.resize(n, 0);
        sz.resize(n,1);
        for (long long i = 0; i < n; i++)
            par[i] = i;
    }

    long long find(long long x) {
        if (par[x] == x)
            return x;
        else 
            return par[x] = find(par[x]);
    }

    void unite(long long x, long long y) {
        x = find(x), y = find(y);
        if (x == y)
            return ;
        
        if (h[x] < h[y])
            swap(x, y);
        
        sz[x] += sz[y];
        sz[y] = sz[x];
        par[y] = x;
        if (h[x] == h[y])
            h[x]++;
    }

    bool same(long long x, long long y) {
        return find(x) == find(y);
    }
    
    int size(long long x) {
        return sz[x] = sz[find(x)];
    }
};

int main() {
    ll n, m;   cin >> n >> m;
    union_find uf(n);
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    vector<ll> cnt(m+1);
    cnt[m] = n*(n-1)/2;
    for (int i = m-1; i >= 0; i--) {
        
        if (uf.same(a[i], b[i])) {
            cnt[i] = cnt[i+1];
            continue;
        }
        cnt[i] = cnt[i+1] - (ll)uf.size(a[i])*(ll)uf.size(b[i]);
        uf.unite(a[i], b[i]);
    }

    for (int i = 1; i <= m; i++)
        cout << cnt[i] << endl;

    return 0;
}


Measured memory_bytes: 7084
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    deque<ll> l;
    l.push_front(-1e6);
    FOR(i,0,n){
        if(s[i]=='o' && l.front()+c<i)l.push_front(i);
        if((ll)l.size()==k+1)break;
    }
    l.pop_back();
    
    deque<ll> r;
    r.push_front(1e6);
    FORr(i,0,n-1){
        if(s[i]=='o' && i+c<r.front())r.push_front(i);
        if((ll)r.size()==k+1)break;
    }
    r.pop_back();
    vector<ll> ans;

    FOR(i,0,k){
        if(r.front()==l.back())ans.push_back(r.front());
        r.pop_front();
        l.pop_back();
    }
    FOR(i,0,ans.size()){
        cout<<ans[i]+1;
        if(i==(ll)ans.size()-1)cout<<endl;
        else cout<<" ";
    }
    
    
}

Measured memory_bytes: 6424
#include<iostream>
#include<string>
using namespace std;
 
int temp;
 
class dice {
public:
        int y, miny, x, minx, z, minz;
        dice() { y = 1, miny = 6, minz = 2, z = 5, x = 3, minx = 4; }
        void North(dice& a){
                temp = y;
                y = minz;
                minz = miny;
                miny = z;
                z = temp;
        }
        void South(dice& a){
                temp = z;
                z = miny;
                miny = minz;
                minz = y;
                y = temp;
        }
        void West(dice& a){
                temp = y;
                y = x;
                x = miny;
                miny = minx;
                minx = temp;
        }
        void East(dice& a){
                temp = minx;
                minx = miny;
                miny = x;
                x = y;
                y = temp;
        }
        void Left(dice& a){
                temp = minz;
                minz = minx;
                minx = z;
                z = x;
                x = temp;
        }
        void Right(dice& a){
                temp = x;
                x = z;
                z = minx;
                minx = minz;
                minz = temp;
        }
};
 
int main(){
        int n,result;
        string d;
        while(cin>>n){
                if(n==0) break;
                dice a;
                result = 0;
                while(n--){
                        cin>>d;
                        if(d == "North") a.North(a);
                        else if(d == "South") a.South(a);
                        else if(d == "West") a.West(a);
                        else if(d == "East") a.East(a);
                        else if(d == "Left") a.Left(a);
                        else if(d == "Right") a.Right(a);
                        result += a.y;
                }
                cout<<result+1<<endl;
        }
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Scanner scan = new Scanner(System.in);
        for (int i = 0; i < 6; i++) {
            list.add(scan.nextInt());
        }

        boolean isYes = list.stream().collect(
                Collectors.groupingBy(x -> x, Collectors.counting())).entrySet().stream().noneMatch(x -> x.getValue() >= 3);
        System.out.print(isYes ? "YES" : "NO");
    }
}


Measured memory_bytes: 27728
import java.time.Year;
import java.util.*;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    // input
    static int a;
    static int b;
    static int c;

    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        sc.close();
    }
 

    /**
     * solver
     */
    static void solve(){
        ArrayList<Integer> l = new ArrayList<>();
        l.add(a);
        l.add(b);
        l.add(c);
        Collections.sort(l);

        int ans = l.get(0) * l.get(1) / 2;

        System.out.println(ans);
    }


    public static void main(String args[]) {

        input();

        solve();
    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct node {
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
}Node;
Node *root;



void insert(Node *z){
  Node *y = NULL;
  Node *x = root;
  while(x!=NULL){
    y=x;
    if((z->key)<(x->key))x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==NULL)root=z;
  else if(z->key<y->key)y->l=z;
  else y->r=z;
}
void inorder(Node *node){
  if(node==NULL){
    return;
  }
  inorder(node->l);
  cout<<" "<<node->key;
  inorder(node->r);
}
void preorder(Node *node){
  if(node==NULL){
    return;
  }
    cout<<" "<<node->key;
    preorder(node->l);
    preorder(node->r);
}
bool find(Node *node,int k){
  if(node==NULL){
    return 0;
  }
  if(node->key==k){
    //cout<<"yes"<<endl;
    return 1;
  }
  else if(node->key<k)find(node->r,k);
  else find(node->l,k);

}
int main(){
  int n,i,k;
  Node *tmp;
  bool flag=0;
  string str;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>str;
    flag=0;
    if(str=="insert"){
      tmp=(Node *)malloc(sizeof(Node));
      tmp->p=tmp->l=tmp->r=NULL;
      cin>>tmp->key;
      insert(tmp);
    }
    else if(str=="find"){
      cin>>k;
      flag=find(root,k);
      if(flag)cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
    else{
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
  }


  return 0;
}



Measured memory_bytes: 21852
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;


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

   cout << (s < t ? "Yes" : "No") << endl;
}

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

int main() {
    int a,b,c,min,mid,max;
    cin >> a >> b >> c;
    max = a;
    if(max < b) {
    	max = b;
    }
    if(max < c) {
    	max = c;
    }
    
    min = a;
    if(min > b) {
    	min = b;
    }
    if(min > c) {
    	min = c;
    }
    
    mid = a;
    if((min == a || min == b) && (max == a || max == b))  {
    	mid = c;
    }
    if((min == b || min == c) && (max == b || max == c))  {
    	mid = a;
    }
       if((min == c || min == a) && (max == c || max == a))  {
    	mid = b;
    }

    cout << min << " " << mid << " " << max << endl;
    return 0;
}


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

int N,M;
int G[111][111];
int ans;

bool check(vector<int> v,int id){
  if( v.empty() ) return true;
  for(int i=0;i<(int)v.size();i++)
    if( G[v[i]][id] == 0 ) return false;  
  return true;
}

void result(const vector<int> &v){
  if( v.size() < 2 ) return;
  int res = 0;
  for(int i=0;i<(int)v.size();i++){
    int ret = (1<<29);
    for(int j=0;j<(int)v.size();j++){
      if( i == j ) continue;
      ret = min( ret, G[v[i]][v[j]] );
    }
    res += ret;
  }
  ans = max ( res, ans );
}

void solve(int id,vector<int> v){
  if( id == N ) {
    result(v);
    return;
  }
  solve(id+1,v);
  if( check(v,id) ){
    v.push_back(id);
    solve(id+1,v);
  } 
}

int main(){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    G[a][b] = c;
    G[b][a] = c;
  }
  solve(0,vector<int>());
  cout << ans << endl;
}

Measured memory_bytes: 1284
N,M=map(int, input().split())
H=list(map(int, input().split()))
D=[list(map(int, input().split())) for _ in range(M)]
G=[1]*N
for a,b in D:
  a-=1
  b-=1
  if H[a]>H[b]:
    G[b]=0
  elif H[a]<H[b]:
    G[a]=0
  else:
    G[a]=0
    G[b]=0
print(sum(G))

Measured memory_bytes: 31896
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdint>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
int N; cin >> N;
vector<int> H(N);
int count = 0;
rep(i,N){
	cin >> H[i];
}

rep(i, N-1){
	
	if(H[i] < H[i+1]){
		count++;
		
		H[i+1] -= 1;
	}
	else if(H[i] == H[i+1]){
		count++;
		
	}
	else{
		
	}	
}	
	if(count  == N -1 ){
		cout << "Yes" << endl;
 	}
	else{
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 640
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1153&lang=jp

#include <iostream>
#include <algorithm>
using namespace std;

void wa() {
  printf("%d\n", -1);
}

int main() {
  int n, m, s;
  while(scanf("%d%d", &n ,&m) != EOF && n && m) {
    int sum[2]; // 合計点
    sum[0] = sum[1] = 0;
    int cards[2][100]; // カード
    for (int i=0; i<n; i++) {
      scanf("%d", &s);
      cards[0][i] = s;
      sum[0] += s;
    }
    for (int i=0; i<m; i++) {
      scanf("%d", &s);
      cards[1][i] = s;
      sum[1] += s;
    }
    if ( (sum[0] - sum[1]) %2 != 0 ) {
      wa();
      continue;
    }
    int dif = (sum[0] - sum[1])/2;
    sort(cards[0], cards[0]+n);
    sort(cards[1], cards[1]+m);
    int cura = 0;
    int curb = 0;
    while (cura < n && curb < m) {
      if (cards[0][cura] - cards[1][curb] == dif) {
	printf("%d %d\n", cards[0][cura], cards[1][curb]);
	goto END;
      } else if (cards[0][cura] - cards[1][curb] > dif) {
	curb++;
      } else {
	cura++;
      }
    }
    wa();
  END: continue;
  }
}

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

int main() {
    int n; cin >>n;
    // 2^100 = ‭1,267,650,600,228,229,401,496,703,205,376‬: 総当たりはできない
    vector<int> s(n);
    int ans = 0; // 最大は100点 x 100問 = 10000(ただしこれは0点となる)
    for (int i = 0; i < n; i++) {cin >>s[i]; ans+=s[i];}
    // 昇順にソートして、ansが10の倍数でなくなるまで引いていく // 間違い：b07, b09でWA
    // →小さなものから引いていく（10の倍数ならまた加える）、すべてのケースで10の倍数なら出たところで0にする
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        if (ans%10!=0) break;
        ans -= s[i];
        if (ans%10!=0) break;
        ans += s[i];
    }
    if (ans%10==0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n  = in.nextInt();
        long[] a = new long[n];
        a[0] = in.nextInt();
        for(int i = 1; i < n; i++) {
            a[i] = in.nextLong() + a[i - 1];
        }
        Map<Long, Long> map = new HashMap<>();
        map.put(0L, 1L);
        for(long key: a) {
            Long val = map.get(key);
            map.put(key, val == null ? 1L : val + 1L);
        }
        long ans = 0;
        for(long key : map.keySet()) {
            Long val = map.get(key);
            if(val > 1) {
                ans += (val * (val - 1)) / 2;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 89084
A, B = map(int, input().split())
import math
N = math.ceil(A / 0.08)
n = math.ceil(B / 0.1)
M = max(N, n)
m = min(N, n)
ans = -1
for i in range(m, M+1):
  if int(i*0.08) == A and int(i*0.1) == B:
    ans = i
    break
print(ans)

Measured memory_bytes: 9220
#include<iostream>

using namespace std;

int main(){
    int a_en, b_en, ab_en, x, y;
    cin >> a_en >> b_en >> ab_en >> x >> y;

    unsigned long long ans = 0;
    if(a_en+b_en > ab_en*2){
        int tmp = min(x,y);
        ans += ab_en * tmp * 2;
        x -= tmp;
        y -= tmp;
    }
    if(a_en > ab_en*2){
        ans += ab_en * x * 2;
        x = 0;
    }
    if(b_en > ab_en*2){
        ans += ab_en * y * 2;
        y = 0;
    }
    ans += a_en * x;
    ans += b_en * y;

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
W, H = map(int, input().split())
m = [list(map(int, input().split())) for i in range(H)]
dx = [[1, 1, 1, 0, -1, 0], [0, 1, 0, -1, -1, -1]]
dy = [-1, 0, 1, 1, 0, -1]
def dfs(x, y):
    if m[y][x] != 0:
        return
    m[y][x] = 2
    for xx, yy in zip(dx[y % 2], dy):
        tx, ty = x + xx, y + yy
        if 0 <= tx < W and 0 <= ty < H:
            dfs(tx, ty)

for x in range(W):
    dfs(x, 0)
    dfs(x, H - 1)
for y in range(H):
    dfs(0, y)
    dfs(W - 1, y)

from itertools import product
n = 0
for x, y in product(range(W), range(H)):
    if m[y][x] != 1:
        continue
    fn = n
    for xx, yy in zip(dx[y % 2], dy):
        tx, ty = x + xx, y + yy
        if 0 <= tx < W and 0 <= ty < H:
            if m[ty][tx] == 2:
                n += 1
        else:
            n += 1
print(n)

Measured memory_bytes: 12564
#include <iostream>
#include <vector>
using namespace std;
#define FREE -1
#define EXIST 1
#define SUCCESS 1
#define SIZE 8
int row[10], col[10];
int crsR[20], crsL[20];

int solve(int r) {
  if (r == SIZE) {
    return SUCCESS; 
  } else if (row[r] != FREE) {
    return solve(r+1);
  } else {
    for (int c = 0; c < SIZE; c++) {
      if (col[c] == FREE && crsR[r+c] == FREE && crsL[r-c+SIZE-1] == FREE) {
        row[r] = c;
        col[c] = r;
        crsR[r+c] = EXIST;
        crsL[r-c+SIZE-1] = EXIST;
        if (solve(r+1) == SUCCESS) {
          return SUCCESS;
        }
        col[c] = FREE;
        crsR[r+c] = FREE;
        crsL[r-c+SIZE-1] = FREE;
      }
    }
    row[r] = FREE;
    return 0;
  }
}

int main() {
  for (int i = 0; i < SIZE; i++) {
    row[i] = col[i] = FREE;
  }
  for (int i = 0; i < SIZE*2; i++) {
    crsR[i] = crsL[i] = FREE;
  }
  
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int r, c;
    cin >> r >> c;
    row[r] = c;
    col[c] = r;
    crsR[r+c] = EXIST;
    crsL[r-c+SIZE-1] = EXIST;
  }

  solve(0);

  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      cout << (row[i] == j ? 'Q' : '.');
    }
    cout << endl;
  }
}




Measured memory_bytes: 3116
<?php

fscanf(STDIN, "%d", $N);
for ($i = 0; $i < $N; $i++) {
    $es = fscanf(STDIN, "%d %d %d");
    sort($es);
    $isRight = $es[0] * $es[0] + $es[1] * $es[1] === $es[2] * $es[2];
    echo $isRight ? 'YES' : 'NO';
    echo PHP_EOL;
}

Measured memory_bytes: 6572
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    n, y = map(int, sys.stdin.readline().split())

    for i in range(y // 10000 + 1):
        for j in range((y - 10000 * i) // 5000 + 1):
            k = n - i - j
            if 10000 * i + 5000 * j + 1000 * k == y:
                print(i, j, k)
                sys.exit()
    else:
        print('-1 -1 -1')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, s, g) for(int i = s; i < g; i++)
#define FORR(i, s, g) for(int i = s - 1; i >= g; i--)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define DMP(a) std::cerr << #a << " = " << std::a << "\n"
using namespace std;
typedef long long ll;
struct aaa{
    aaa(){
        std::cin.tie(0); std::ios::sync_with_stdio(0); std::cout<<std::fixed<<std::setprecision(20);
    };
}aaaaaaa;

int main() {
    int n, m, l = 0, r = 100000 + 1;
    cin >> n >> m;
    REP(i, m) {
        int tl, tr;
        cin >> tl >> tr;
        l = max(tl, l);
        r = min(tr, r);
    }

    cout << (r >= l ? r - l + 1 : 0) << "\n";

    return 0;
}


Measured memory_bytes: 256
import fractions
from functools import reduce

N = int(input())
a = list(map(int, input().split()))

left = [0] * (N+1)
right = [0] * (N+1)

for i in range(N):
    left[i+1] = fractions.gcd(left[i], a[i])
    right[N-i-1] = fractions.gcd(right[N-i], a[N-1-i])

ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(left[i], right[i+1]))

print(ans)


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


vector<ll> func(ll x){
    vector<ll> num(50,0);
    if(x < 0){return num;}
    for(int i = 0; i < 50; i++){
        ll b = 1LL << (i+1);
        ll q = x/b;
        ll r = x%b;
        num[i] = q*b/2 + max(r-(b/2-1),0LL);
    }
    return num;
}
int main(){
    ll a, b;
    cin >> a >> b;
    vector<ll> av = func(a-1);
    vector<ll> bv = func(b);
    ll ans = 0;
    for(int i = 0; i < 50; i++){
        ll tmp = (bv[i] - av[i])%2;
        if(tmp == 1){ans += 1LL << i;}
    }
    cout << ans << endl;


    return 0;
}


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

class Progaram
{
    static void Main(String[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var n = l[0]; var m = l[1];
        Console.WriteLine((n - 1) * (m - 1));
    }
}

Measured memory_bytes: 11220