akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

/*
vector < int > tree(400005);

void buildtree (vector < int > v,int node,int start,int fin)
  {
      if(start==fin)
      {
          tree[node]=v[start];
          return;
      }
      int mid=(start+fin)/2;
      buildtree(v,2*node,start,mid);
      buildtree(v,2*node+1,mid+1,fin);
      tree[node]=tree[2*node]+tree[2*node+1];
  }

 int sum (int node,int tl,int tr,int l , int r)
   {
       if(l>r) return 0;
       if(l==tl and r==tr) return tree[node];
       int mid=(tl+tr)/2;
       return sum(2*node,tl,mid,l,min(r,mid))+sum(2*node+1,mid+1,tr,max(l,mid+1),r);
   }

  void update(int node,int tl , int tr,int pos,int val)
    {
        if(tl==tr) {tree[node]=val; return;}
        int mid=(tl+tr)/2;
        if(pos<=mid)
              update(2*node,tl,mid,pos,val);
        else
            update(2*node+1,mid+1,tr,pos,val);
        tree[node]=tree[2*node]+tree[2*node+1];

    } */

bool check(string &st,int f,int s,int l,int n,char c)
{
    ll k = 0;
    for(int i=0;i<l;i++)
    {
        if(st[(i+s)%n]==c)
            k++;
    }
    if(k>=f)    return true;
    return false;
}
int LS(vector < int > &v,int i,int c)
 {
     int n=v.size();
     vector < int > vp;
     int k=i;
     for(i;i<n;i++) vp.pb(v[i]);
    n=vp.size();
    int lis[n];
    lis[0] = 1;
     if(c==1) return 1;
     for ( i = 1; i < n; i++ )
    {
        lis[i] = 1;
        for (int j = 0; j < i; j++ )
            if ( vp[i] > vp[j] && lis[i] < lis[j] + 1)
                lis[i] = lis[j] + 1; {if(lis[i]==c) return i;}
    }
    //rep(i,0,n) cout<<lis[i]<<" ";
   // cout<<endl;
    return 0;
 }

 void solve()
{
ll int i,j=0,r=200,p,q,k=100005,d,y=1,h,flag=1,n,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,ans=0,l;
//vector < pair < int , pair < int , int > > >vp(n);s
string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy";
    else cout<<"Sunny";
    

}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   //cin>>t;
    while(t--)
    solve();
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,v,p;
ll m;
const int Maxn=1e5+5;
ll a[Maxn];
ll pre[Maxn];
bool check(int mid){
	if(mid<=p)return true;
	if(a[mid]+m<a[p])return false;
	int cnt=v-(p+n-mid);
	if(cnt<=0)return true;
	return cnt*m+(pre[mid-1]-pre[p-1])<=(a[mid]+m)*(mid-p);
}
int main(){
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		pre[i]=a[i]+pre[i-1];
	}
	int l=1,r=n+1;
	while(r-l>1){
		int mid=(l+r)/2;
		if(check(mid))l=mid;
		else r=mid;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1792
package main

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

var par []int

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	par = make([]int, n)
	for i := range par {
		par[i] = i
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		a--
		b--
		unite(a, b)
	}

	pc := make([]int, n)
	for i := range par {
		r := root(par[i])
		pc[r]++
	}
	mx := 0
	for _, v := range pc {
		mx = max(mx, v)
	}

	fmt.Println(mx)
}

func root(x int) int {
	if par[x] == x {
		return x
	}
	par[x] = root(par[x])
	return par[x]
}

func unite(x, y int) {
	rx := root(x)
	ry := root(y)
	if rx == ry {
		return
	}
	par[rx] = ry
}

func same(x, y int) bool {
	return root(x) == root(y)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 20012
#include <stdio.h>

int main(void) {
	int n, x;
	while (scanf("%d%d", &n, &x) == 2 && (n|x) != 0) {
		int i, j;
		int count = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				int k = x - i - j;
				if (j < k && k <= n) count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

vll n;


int main(){
  n = vll(4);
  for(lli i = 0;i < 4;i++){
    char a;
    cin >> a;
    n[i] = a-'0';
  }
  for(lli i = 0;i < 8;i++){
    lli x = n[0];
    for(lli j = 1,k = 1;j < 8;j <<= 1,k++){
      if((i&j) == 0) x += n[k];
      else x -= n[k];
    }
    if(x == 7){
      cout << n[0];
      for(lli j = 1,k = 1;j < 8;j <<= 1,k++){
        if((i&j) == 0) cout << '+';
        else cout << '-';
        cout << n[k];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
typedef long long ll;
const int N=2e5+9;
struct sa
{
    int x;
    int y;
};
int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)!=-1)
    {
        if(a>=13)
            cout<<b<<endl;
        if(a>=6&&a<=12)
            cout<<b/2<<endl;
        if(a<=5)
            cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i, m, n) for(int i=(m);i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int n;

  while( cin >> n, n ) {
    vector<Pip> v;
    bool flag = false;

    Rep(i, n) {
      int m, a, b;
      cin >> m >> a >> b;
      v.pb(Pip(a, Pii(b, m)));
    }
    sort(All(v));
    
    Rep(i, n) {
      Pip p = v[i];
      int m = p.sc.sc, a = p.fr, b = p.sc.fr;
      int sum = m;
      
      Rep(j, i) {
	Pip p_ = v[j];
	int m_ = p_.sc.sc, a_ = p_.fr, b_ = p_.sc.fr;
	if( b_ > a ) {
	  sum += m_;
	}
      }
      
      if( sum > 150 ) {
	flag = true;
      }
    }

    if( flag ) cout << "NG" << endl;
    else cout << "OK" << endl;
  }

}

Measured memory_bytes: 1188
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int64 calc(const vector<int64>& a, const vector<int64>& s) {
    int64 res = 0;
    int64 pre = 0;
    int n = a.size();
    auto si = s.begin();
    for (int i=0; i<n; i++) {
        int ad = 0;
        if (i == *si) {
            ad = max(0LL, pre - a[i] + 1);
            res += ad;
            if (++si == s.end()) break;
        }
        pre = max(pre, a[i] + ad);
    }
    return res;
}

int64 dfs(const int& i, const int& k, const vector<int64>&a, vector<int64> s) {
    if (s.size() == k) return calc(a,s);
    if (i >= a.size()) return LONG_MAX;
    int64 res = LONG_MAX;

    res = min(res, dfs(i+1, k, a, s));
    s.push_back(i);
    res = min(res, dfs(i+1, k, a, s));
    return res;
}


int main() {
    int n,k;
    cin >> n >> k;
    vector<int64> a(n);
    for (int i=0; i<n; i++) cin >> a[i];

    vector<int64> s;
    int64 ans = dfs(0, k, a, s);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans<<"\n";
}

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

    solve();
    return 0;
}

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

b = 0
q = 0
for s in S:
    if (s == 'a' and q < A+B) or (s == 'b' and q < A+B and b < B):
        print('Yes')
        q += 1
    else:
        print('No')
    if s == 'b':
        b += 1


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

int N, M;
set<int> dev;

int main() {
    cin >> N >> M;
    for (int i = 1; i*i <= M; i++) {
        if (M%i) continue;
        dev.insert(i);
        dev.insert(M/i);
    }
    int res;
    for (auto iter = dev.begin(); iter != dev.end(); iter++) {
        if (*iter >= N) {
            res = M / *iter;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	n   int
	cur []int
	op  []int
)

func insert(j int) {
	for i := n; i > j; i-- {
		cur[i] = cur[i-1]
	}
	cur[j] = j
}

func remove(index int) {
	for i := index; i < n; i++ {
		cur[i] = cur[i+1]
	}
	cur[n] = 0
}

func check() bool {
	for i := 1; i <= n; i++ {
		if cur[i] > i {
			return false
		}
	}
	return true
}

func solve(depth int) bool {
	if !check() {
		return false
	}

	if depth == 0 {
		return true
	}

	for j := 1; j <= depth; j++ {
		if j == cur[j] {
			remove(j)
			op[depth] = j
			if solve(depth - 1) {
				return true
			}
			op[depth] = 0
			insert(j)
		}
	}

	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	g := strings.Fields(scanner.Text())

	cur = make([]int, n+1)
	op = make([]int, n+1)
	for i := 1; i <= n; i++ {
		cur[i], _ = strconv.Atoi(g[i-1])
	}

	if solve(n) {
		for i := 1; i <= n; i++ {
			fmt.Println(op[i])
		}
	} else {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	cout << (N - i) + 1 << endl;
}

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, p;
	scanf("%d %d",&a,&p);
	
	p += a*3;
	
	printf("%d\n",p/2);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
    cout<<n*(n-1)/2-k<<endl;
    rep2(i,2,n+1)cout<<1<<" "<<i<<endl;
    int res=(n-1)*(n-2)/2-k,u=2,v=3;;
    while(res>0){
        cout<<u<<" "<<v<<endl;
        if(v==n){
            u++;
            v=u+1;
        }
        else v++;
        res--;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define mx 3000008
#define ll long long int
int a[mx];
int cnt[mx];
int cnt1[mx];
int main()
{
    ll a,b,c;
    string s;
    cin>>a>>b>>c;
    ll ans=1000000009;
    if(a%2==0 || b%2==0 || c%2==0) {
        ans=0;
        cout<<0<<endl;
        return 0;
    }

    ll x=b*c;
    ll y=a*b;
    ll z=a*c;
    ans=min(x,min(y,z));

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5;
int main(){
	int N,L;
	cin>>N>>L;
	int sum=0;
	for(int i=L;i<=N+L-1;i++){
		sum+=i;
	}
	if(L<=0 && L+N-1>=0){
		sum+=0;
	}
	else if(L<0 && L+N-1<0){
		sum-=L+N-1;
	}
	else if(L>0){
		sum-=L;
	}
	cout<<sum;
	return 0;
}

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

int main() {
  int N, M;
  while (cin >> N >> M, N) {
    auto a = vector<int>(M + 1, 0);
    for (int i = 0; i < N; ++i) {
      int d, v; cin >> d >> v;
      a[d] = max(a[d], v);
    }
    int ans = accumulate(begin(a), end(a), 0);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;
#include <map>

using ll = long long;
using namespace std;


int main(){
    int n, m;
    map<string, int> m_l;
    string s;

    cin >> n;
    rep(i, n){
        cin >> s;
        m_l[s]++;
        }
    
    cin >> m;
    rep(i, m){
        cin >> s;
        m_l[s]--;
        
    }

    int max_num=0;
    for (auto it = m_l.begin(); it!=m_l.end(); it++){
        max_num = max(max_num, it->second);

    }
    cout << max_num << endl;

}

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

using namespace std;



int main()
{
	int n,ans=0;
	cin >> n;
	vector <int> l(n);

	for (int i = 0;i < n;i++) cin >> l[i];

	sort(l.begin(), l.end());
	for (int i = 0;i < n - 1;i++)
	{
		ans += l[i];
	}
	if (ans > l[n - 1])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc005.contest.atcoder.jp/tasks/agc005_b>
問題文============================================================
 すぬけ君はある日友人から長さ N の順列 a1,a2,…,aN を貰いました。
 
 Σ{l = 1..N}Σ{r = l..N} min(al,al+1,...,ar)
 
 を求めてください。
 
 制約
 1≦N≦200,000
 (a1,a2,…,aN) は (1,2,…,N) を並び替えたものである

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> b(N+1,0);
    for(int i = 1; i <= N;i++){
        ll a; cin >> a;
        b[a] = i;
    }
    set<ll> s; s.insert(0); s.insert(N+1);
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        auto it = s.lower_bound(b[i]);
        ans += i * (*it - b[i]) * (b[i] - *(--it));
        s.insert(b[i]);
    }
    cout << ans << endl;
	return 0;
}


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

int n,m,q,ans=0;
vector<int>a,b,c,d;

void dfs(vector<int>x){
    if(x.size()==n+1){
        int cnt=0;
        rep(i,q){
            if(x[b[i]]-x[a[i]]==c[i])cnt+=d[i];
        }
        ans=max(ans,cnt);
        return;
    }
    x.push_back(x.back());
    while(x.back()<=m){
        dfs(x);
        x.back()++;
    }
}

int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(vector<int>(1,1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
n, k = map(int,input().split())
lsa = list(map(int,input().split()))
ls = [0 for i in range(2 * (10 ** 5))]
for i in range(n):
    ls[lsa[i] - 1] += 1
ls2 = [i for i in ls if i != 0]
ls2.sort()

ans = 0

if len(ls2) > k:
    t = len(ls2) - k
    ls3 = [ls2[i] for i in range(t)]
    ans += sum(ls3)

print(ans)


Measured memory_bytes: 32264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[5];
  int k;
  //n>>a>>b>>c>>d>>e>>k;
  	for(int i=0;i<5;i++)
      	cin>>arr[i];
    cin>>k;
  	for(int i=0;i<4;i++)
    {
		for(int j=i+1;j<5;j++)
        {
			if(abs(arr[i]-arr[j])>k)
            {
				cout<<":(";
              return 0;
            }
        }
    }
  cout<<"Yay!";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
//#define gcd __gcd
//#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

//OJ freopen Template
void OJF(const char* inp, const char* out) {
	if (strlen(inp) > 0) freopen(inp, "r", stdin);
	if (strlen(out) > 0) freopen(out, "w", stdout);
}

const int inf = INT_MAX;

signed main()
{
    //OJF("TRAIGLE.inp", "TRIAGLE.out");
	fastio();

	int n, k; cin >> n >> k;
	vector<int> h(n);
	rep(i, 0, n) cin >> h[i];

	int dp[n + 1];

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	for (int i = 2; i < n; i++) {
        dp[i] = inf;
        for (int j = 1; j <= min(k, i); j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
	}

	cout << dp[n - 1];
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayDeque;
import java.awt.Point;

public class Main{

public static int psum(int [][]house,int h,int w){
int ret=0;

for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)if(house[j][i]==1)ret++;
}
  return ret;
}
	
public static Point pfound(int [][]house,int h,int w){
for(int i=0;i<h;i++){
  for(int j=0;j<w;j++)if(house[j][i]==1)return new Point(j,i);
}
  return new Point(-1,-1);
}

public static int kukaku(int[][]house,int h,int w){
	int cnt=psum(house,h,w);
	Point[] Dir={new Point(1,0),new Point(1,1),new Point(0,1),new Point(-1,1),new Point(-1,0),new Point(-1,-1),new Point(0,-1),new Point(1,-1)};
	int ret=0;
	ArrayDeque<Point>dq=new ArrayDeque<>();
	while(cnt>0){
		Point fpt=pfound(house,h,w);
		if(fpt.x==-1 && fpt.y==-1)return ret;
		dq.add(fpt);
		ret++;
		
		while(dq.size()>0){
			Point p=dq.removeFirst();
			house[p.x][p.y]=0;
			for(int i=0;i<8;i++){
				Point np=new Point(p.x+Dir[i].x,p.y+Dir[i].y);
			 	int nx=np.x;int ny=np.y;
				if(nx>=0 && nx<w && ny>=0 && ny<h && house[nx][ny]==1){dq.addLast(new Point(nx,ny));
				cnt--;house[nx][ny]=0;
				}
			
			}
		}
		
	}
return ret;
}


public static void main(String []ag){
Scanner sc=new Scanner(System.in);
int h=0,w=0;
do{
	w=sc.nextInt();
	h=sc.nextInt();
	int [][]house=new int[w][h];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)house[j][i]=sc.nextInt();
	}
	int ret=kukaku(house,h,w);
	if(h!=0 || w!=0)System.out.printf("%d\n",ret);
}while(h!=0 || w!=0);

}

}



Measured memory_bytes: 51552
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 100050
int n,a[N];
int gcd(int x,int y) {return y?gcd(y,x%y):x;}
void print(int x) {
	puts((x&1)?"First":"Second");
	exit(0);
}
int main() {
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	int cas=0;
	for(;;cas++) {
		int i,flg=0,s=0,odd=0;
		for(i=1;i<=n;i++) {
			if(a[i]==1) flg=1;
			s+=(a[i]-1);
			if(a[i]&1) odd++;
		}
		if(flg==1) print(cas+s);
		if(s&1) print(cas+1);
		if(odd>1) print(cas);
		for(i=1;i<=n;i++) if(a[i]&1) a[i]--;
		int t=0;
		for(i=1;i<=n;i++) t=gcd(a[i],t);
		for(i=1;i<=n;i++) a[i]/=t;
	}
}


Measured memory_bytes: 512
n,k,*a=map(int,open(i:=0).read().split())
a.sort()
p=a.pop
s=b=~k%2or p()
while k>1:
 if(x:=a[i]*a[i+1])*b>a[-1]*a[-2]*b:s*=x;i+=2
 else:s*=p()*p()
 s%=10**9+7;k-=2
print(s)

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

int main(){
  int i,j,n,x[100],y[100];
  double p,max;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&x[i]);

  for(i=0;i<n;i++)
    scanf("%d",&y[i]);

  for(j=1;j<=3;j++){
    p=0.0;
    for(i=0;i<n;i++){
      p += pow((abs(x[i]-y[i])),j);
    }
    p = pow(p,1.0/j);
    printf("%f\n",p);
  }
  max = abs(x[0]-y[0]);
  for(i=1;i<n;i++)
    if(max < abs(x[i]-y[i]))max = abs(x[i]-y[i]);
 
  printf("%f\n",max);
  return 0;
}

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

char s[15],t[15];

int main() {
	scanf("%s%s",s,t);
	for(int i=0;s[i];++i)
		if (s[i] != t[i]) {
			cout << "No"<<endl;
			return 0;
		}
	cout << "Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<int> h(n);
    rep(i,0,n) cin >> h[i];
    V<int> dp(n);
    dp[n-1] = 0;
    dp[n-2] = abs(h[n-2] - h[n-1]);
    rep(i,n-2,0) dp[i] = min(dp[i+1]+abs(h[i]-h[i+1]), dp[i+2]+abs(h[i]-h[i+2]));
    cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int c[10][1005];

int main() {
  int h,w,k; cin >> h >> w >> k;
  int ans = 1001001001;
  string s[h];
  FOR(i,0,h-1){
    cin >> s[i];
  }

  FOR(b,0,bit(h-1)-1){
    int g = 0;
    int id[h];
    FOR(i,0,h-1){
      id[i] = g;
      if(b & bit(i)) ++g;
    }
    FOR(i,0,h-1){
      FOR(j,0,w-1){
        c[i][j] = 0;
      }
    }
    FOR(i,0,h-1){
      FOR(j,0,w-1){
        c[id[i]][j] += s[i][j] - '0';
      }
    }
    ++g;

    int num = g-1;
    int now[g];
    FOR(i,0,g-1) now[i] = 0;
    FOR(j,0,w-1){
      FOR(i,0,g-1) now[i] += c[i][j];
      bool ok = true;
      FOR(i,0,g-1){
        // cout << j << " " << i << " " << now[i] << "\n";
        if(now[i]>k) ok = false;
      }
      if(!ok){
        ++num;
        FOR(i,0,g-1) now[i] = 0;
        FOR(i,0,g-1) now[i] += c[i][j];
        ok = true;
        FOR(i,0,g-1){
          if(now[i]>k) ok = false;
        }
        if(!ok){
          num = 1001001001;
          break;
        }
      }
    }
    // cout << num << "\n";
    chmin(ans,num);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
# sys.setrecursionlimit(10**6)
#------------------------------------------------------------------


n = int(input())
a = []
for i in range(2):
    a.append(list(mapi()))
f = 0
for i in range(2,n):
    a.append(list(mapi()))
    if a[i][0]==a[i][1] and a[i-1][0]==a[i-1][1] and a[i-2][0]==a[i-2][1]:
        f = 1
if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9752
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll k,n,h[100005],h1[100005];
    cin>>n>>k;
    for(int i=1; i<=n; i++)cin>>h[i];
    for(int i=2; i<=n; i++)h1[i]=INT_MAX;
    h1[1]=0;
    h1[0]=0;
    h[0]=h[1];
    for(int i=2; i<=n; i++)
    {
        for(int j=1; j<=k; j++)
        {
            if(j<i)
            {
                if((abs(h[i]-h[i-j])+h1[i-j])<h1[i])h1[i]=abs(h[i]-h[i-j])+h1[i-j];
            }

        }
    }
    cout<<h1[n];
}


Measured memory_bytes: 1792
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
Q = deque()
for i in range(k):
  Q.append(a[i])
for i in range(k,n):
  head = Q.popleft()
  end = a[i]
  if head<end:
    print('Yes')
  else:
    print('No')
  Q.append(end)

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair



int main() {
    int N; cin >> N;
    int ans = 0;
    FOR(i, 1, N) {
        int d = 0;
        FOR(j, 1, i) {
            if (i % j == 0) d++;
        }
        if (d == 8 && i % 2 == 1) ans++;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 384
//
// Created by Myabu on 2020/01/13.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int N,M;

    cin>>N>>M;

    vector<bool> flag(M, true);

    for (int i = 0; i < N; ++i) {
        int K;
        cin>>K;
        vector<bool> temp_flag(M, false);
        for (int a = 0; a < K; ++a) {
            int temp;
            cin>>temp;
            temp_flag[temp-1] =true;
        }
        for (int b = 0; b < temp_flag.size(); ++b) {
            if(temp_flag[b]){

            }else{
                flag[b] = false;
            }
        }
    }

    int ans = 0;

    for (int i = 0; i < flag.size(); ++i) {
        if(flag[i]){
            ans++;
        }
    }

    cout<<ans<<endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

const int MAX_N = 1 << 17;

//const int F = 2147483647;//(int)(((ll)(2)<<31) -1);
const int F = (1LL<<31)-1;

int n;
unsigned int dat[1000000];//セグメント木

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;

	for(int i = 0; i < 2*n - 1; i++) dat[i] = F;
}

void update(int k, int a){
	k += n-1;
	dat[k] = a;
	while(k > 0){
		k = (k-1) / 2;
		dat[k] = min(dat[k*2 + 1], dat[k*2 + 2]); //RMQ以外はここを変える？
	}
}

//[a,b)の最小値を求める
//kは接点の番号，l,rはその接点が[l,r)に対応していることを示す
//呼ぶときはquery(a,b,0,0,n)
int query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return F;
	
	if(a <= l && r <= b) return dat[k];
	else{
		int vl = query(a, b, k*2 + 1, l, (l+r) / 2);
		int vr = query(a, b, k*2 + 2, (l+r) / 2, r);
		return min(vl, vr);
	}
}

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

	int m,q;
	cin >> m >> q;
	init(m);
	
	int com,x,y;
	for(int i=0;i<q;i++){
		cin >> com >> x >> y;
		if(com == 0) update(x,y);
		else		cout << query(x,y+1,0,0,n) << "\n";
	}
	return 0;
}


Measured memory_bytes: 4200
#pragma GCC optimize("O3")
#define first x
#define second y
#include <bits/stdc++.h>

using namespace std;

enum {MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009};
typedef unsigned short ushort;typedef unsigned int uint;typedef long long ll;typedef unsigned long long ull;
#ifndef CrafterKolyan
#define endl '\n'
#endif

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1e5 + 55;//, mod = 1e9 + 7;
ll a, b;
ll get(ll x) {
	if(x==0) return 0;
	ll t = 1;
	while(t < x) t=t<<1|1;
	return t;
}
ll isect(pi a, pi b) {
	if(a.first >= b.first && b.second <= a.second) return a.second - a.first + 1;
	if(a.second>=b.first) return b.second - a.first + 1;
	return a.second + b.second - a.first - b.first + 2;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> a >> b;
	if(a==b) return cout << 1, 0;
	ll t = 1ll<<60;
	while((a&t)==(b&t)) a = min(a, a^t), b = min(b, b^t), t>>=1;
	pi p = {a, b|get(b^t)}, q = {t|a, 2ll*t-1};
	cout << isect(p, q);
}



Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int read(){
    register int x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define int long long

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


Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  ll N,S=0;
  cin>>N;
  vector<ll> V(N);
  vector<ll> C(N);
  for(int i=0;i<N;i++) cin>>V.at(i);
  for(int i=0;i<N;i++) cin>>C.at(i);
  for(int i=0;i<N;i++){
    if(V.at(i)>C.at(i)) S=S+V.at(i)-C.at(i);
  }
  cout<<S;
return 0;}

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    int x;cin>>x;
    if(x==0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main()
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ans = "";

            if (a[1]*a[2] >= a[0])
            {
                ans = "Yes";
            }
            else
            {
                ans = "No";
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28232
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        k: i32,
        a:i32,
        b:i32,
    }
    if a % k == 0 || b % k == 0 || a / k < b / k {
        println!("OK");
    } else {
        println!("NG");
    }
}


Measured memory_bytes: 2164
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int a , b , c , k ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c >> k ;
	if ( k & 1 )
		cout << - ( a - b ) << '\n' ;
	else
		cout << a - b << '\n' ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int total_yen, ichi_yen_coin_num;
  cin >> total_yen >> ichi_yen_coin_num;
  int surplus = total_yen % 500;
  
  if (total_yen <= ichi_yen_coin_num || surplus == 0 || surplus <= ichi_yen_coin_num) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;


int main(){

	int k = 2;
	cin >>k;

	long long ans = 0;

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

		for(int j = 1; j <= k; j++){

			for(int l = 1; l <=k; l++){
				ans+= __gcd(i, __gcd(j,l));
			}
		}
	}
	
	cout <<ans;

	return 0;
}

Measured memory_bytes: 3636
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getString = BS.unpack <$> BS.getLine

judge :: [Char] -> Int -> Int -> String
judge [] _ _ = ""
judge (s : ss) a b
  | (a == 0) && (b == 0) = "No\n" ++ judge ss a b
  | (s == 'a') && (a > 0) = "Yes\n" ++ judge ss (a -1) b
  | (s == 'a') && (b > 0) = "Yes\n" ++ judge ss a (b -1)
  | (s == 'b') && (b > 0) = "Yes\n" ++ judge ss a (b -1)
  | otherwise = "No\n" ++ judge ss a b

main = do
  [n, a, b] <- getIntList
  s <- getString
  putStrLn $ judge s a b


Measured memory_bytes: 1532
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    vector<int> k((n+1)/2,0);
    ll ans=1;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        k[(n-a-1)/2]++;
        if((n-a-1)%2!=0)ans=0;
    }
    for(int i=0;i<(n+1)/2;i++){
        if(n%2==1&&i==(n+1)/2-1){
            if(k[i]!=1){
                ans=0;
                break;
            }
            continue;
        }
        if(k[i]==2)ans=ans*2%INF;
        else{
            ans=0;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int ans = -1;
  for (int i = 0; i <= 120; i++) {
    int lhs = i * a + i * b,
        rhs = lhs + a;
    if ((lhs % 60 <= c && c <= rhs % 60) ||
        (lhs % 60 <= c && 60 <= (lhs % 60) + a) ||
        (c <= rhs % 60 && 60 <= (lhs % 60) + a)) {
      ans = lhs + c - (lhs % 60);
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1212
k=l=m=n=0
while 1:
	a,b,c=sorted(map(int,raw_input().split()))
	if a+b<=c:break
	k+=1
	if a**2+b**2>c**2:m+=1
	elif a**2+b**2<c**2:n+=1
	else:l+=1
print k,l,m,n

Measured memory_bytes: 4216
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> set = new HashSet<>();
		set.add(sc.nextInt());
		set.add(sc.nextInt());
		set.add(sc.nextInt());
		if (set.size() == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define sz size()
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
const int nmax=300001;
const int mod=1e9+9;
int n, a[200001], j, ans;
map<int, int> m;

int main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        m[a[i]]++;
    }
    sort(a+1, a+n+1);
    for(int i=n; i>=1; i--){
        if(m[a[i]]){
            j=31;
            while((1<<j)-a[i]>0) j--;
            j++;
            if(m[(1<<j)-a[i]] && a[i]!=(1<<j)-a[i]){
                m[(1<<j)-a[i]]--;
                m[a[i]]--;
                ans++;
            }
            else if(m[(1<<j)-a[i]]>=2 && a[i]==(1<<j)-a[i]){
                m[a[i]]-=2;
                ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 19840
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e15+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;

int t=1;
//in t;
int tt=0;
while(t--){
string s;in s;
if(s[0]=='7' || s[1]=='7' || s[2]=='7')
out "Yes";
else out "No";
}
return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<string, int> P;
const int mod = 1000000007;
const int INF = 1e12;

bool myfind(vector<int> &a, int k){
    int n = a.size();
    int l = -1, r = n;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(a[mid] == k) return true;
        if(a[mid] > k) r = mid;
        else l = mid;
    }
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    cin >> q;
    vector<int> b(q);
    rep(i, 0, q) cin >> b[i];
    int ans = 0;
    rep(i, 0, q){
        if(myfind(a, b[i])) ans++;
        // if(find(a.begin(), a.end(), b[i]) != a.end()) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
	string s;
	int n;

	cin >> n;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		s[i] += n;
		if (s[i] > 'Z') s[i] -= 26;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
def ee
    s = gets.chomp
    i = 0
    n = 0
    t = gets.chomp

    if s == t
        puts s.length
        exit
    end

    t.each_char do |c|
        i = s.index(c, i)
        unless i
            i = s.index(c, 0)
            unless i
                puts -1
                exit
            end
            n += 1
        end
        i += 1
    end

    puts n*s.length+i
end

ee

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

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

    l1 = s.size();
    l2 = t.size();

    string ans;
    int i = 0, j = 0;
    while ( 1 ) {
        if ( i >= l1 || j >= l2 ) break;
        //cout << i << " " << j << endl;

        if ( s[i] != t[j] || (isdigit(s[i]) && isdigit(t[j])) )  {
            if ( isdigit(s[i]) && isdigit(t[j]) ) {
                int a = 0;
                int b = 0;
                while ( isdigit(s[i]) ) {
                    a *= 10;
                    a += s[i]-'0';
                    i++;
                }
                while ( isdigit(t[j]) ) {
                    b *= 10;
                    b += t[j]-'0';
                    j++;
                }
                ans += (to_string(a+b));
            } else {
                if ( s[i] == ')' ) {
                    j++;
                    int l = 1;
                    while ( l >= 0 ) {
                        if ( t[j] == '(' ) l++;
                        if ( t[j] == ')' ) l--;
                        j++;
                    }
                    i++;
                } else {
                    i++;
                    int l = 1;
                    while ( l >= 0 ) {
                        if ( s[i] == '(' ) l++;
                        if ( s[i] == ')' ) l--;
                        i++;
                    }
                    j++;
                }
                ans.push_back(')');
            }
        } else{
            ans.push_back(s[i]);
            i++;
            j++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3304