akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 int main() {
    int N, K; cin >> N >> K;
    vector<ll> V(N);
    for (int i = 0; i < N; i++) cin >> V[i];

    ll res = 0;
    for (int p = 0; p <= min(K, N); p++) {
        for (int q = 0; p + q <= min(K, N); q++) {
            vector<ll> v;
            ll cur = 0;
            for (int i = 0; i < p; ++i) {
              v.push_back(V[i]);
              cur += V[i];
            }
            for (int i = 0; i < q; ++i) {
              v.push_back(V[N-1-i]);
              cur += V[N - 1 - i];
            }
            sort(v.begin(), v.end());
            for (int i = 0; i < min(K - p - q, (int)v.size()); ++i) {
                if (v[i] < 0) cur -= v[i];
            }
            res = max(res, cur);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
  int h,w,d,a,i,j,x[90010],y[90010],t[90010]={},q,l,r,ans;
  cin >> h >> w >> d;
  for (i=0;i<h;i++) for (j=0;j<w;j++){
    cin >> a;
    x[a]=i;
    y[a]=j;
  }
  for (i=0;i+d<=h*w;i++){
    t[i+d]+=t[i]+abs(x[i]-x[i+d])+abs(y[i]-y[i+d]);
  }
  
  cin >> q;
  for (i=0;i<q;i++){
    cin >> l >> r;
    cout << t[r]-t[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
main(){
  while(1){
  int a,n[100],i,key,l=0,r,mid,c=0;
    scanf("%d",&a);
    if(a==0) break;
    for(i=0;i<=a;i++){
      scanf("%d",&n[i]);
    }
    key=n[a];
    r=a-1; 
    while(l<=r){
      mid=(l+r)/2;
      c++;
      if(n[mid]==key) break;
      else if(n[mid]<key) l=mid+1;
      else r=mid-1;
    }
    printf("%d\n",c);
  } 
  return 0; 
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

int main()
{
	char s[200001];
	scanf("%s", s);
	int n = strlen(s);
	std::vector<int> pos[2019];
	for (int i = 0, mod = 0, base = 1; i < n; ++i)
	{
		mod = (mod + (s[n - 1 - i] - '0') * base) % 2019;
		pos[mod].push_back(i + 1);
		base = (base * 10) % 2019;
	}
	long long ans = 0;
	for (int i = 0, mod = 0, base = 1; i < n; ++i)
	{
		ans += pos[mod].end() - std::upper_bound(pos[mod].begin(), pos[mod].end(), i);
		mod = (mod + (s[n - 1 - i] - '0') * base) % 2019;
		base = (base * 10) % 2019;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4768
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a;
		String op;
		int b;
		for(int k =1;k>0;k++){
			a = scan.nextInt();
			op = scan.next();
			b = scan.nextInt();
			if(op.equals("+")){
				System.out.println(a+b);
			}else if(op.equals("-")){
				System.out.println(a-b);
			}else if(op.equals("*")){
				System.out.println(a*b);
			}else if(op.equals("/")){
				System.out.println(a/b);
			}else if(op.equals("?")){
				break;
			}
		}
	}
}

Measured memory_bytes: 18032
N = int(input())

P = [1 for i in range(N + 1)]

for i in range(1, N + 1):
    if i * 2 > N:
        break
    for j in range(i * 2, N + 1, i):
        P[j] += 1
        
res = 0

for i in range(N + 1):
    res += i * P[i]

print(res)

Measured memory_bytes: 224880
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
using namespace __gnu_pbds;
const int inf=1e7;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 2e5+5;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

vector <ll> adj[MAX_N];

int main(){
    fastio;
    ll n;
  	cin>>n;
  	f(i,0,n-1){
      	ll num;cin>>num;
    	adj[num].pb(i+2);
    }
  	f(i,1,n+1){
    	cout<<adj[i].size()<<endl;
    }
  
    
    
} 

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

int n;
int a[200010],c[200010];
int ans;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}

bool check(int x){
	int minv=2*1e5;
	for(int i=1;i<2*n;i++){
		if(a[i]>=x) c[i]=1;
		else c[i]=0;
	}
	bool flag=bool(c[1]);
	for(int i=2;i<=n;i++){
		if(c[i]==c[i-1]) {
			if(minv>n-i) {
				minv=n-i;
				flag=bool(c[i]);
			}
		}
	}
	for(int i=n;i<2*n-1;i++){
		if(c[i]==c[i+1]) {
			if(minv>i-n) {
				minv=i-n;
				flag=bool(c[i]);
			}
		}
	}
	return flag;
}

int main(){
	
	n=read();
	for(int i=1;i<2*n;i++){
		a[i]=read();
	}
	int l=1,r=2*n;
	while(l<r){
		int mid=(l+r)>>1;
//		cout<<mid<<' ';
		if(check(mid)){
			ans=mid;
			l=mid+1;
//			cout<<"true"<<' ';
		}
		else {
			r=mid;
//			cout<<"false"<<' ';
		}
//		cout<<endl;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAX = 1e7;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

long long 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 main() {
    COMinit();
    ll x,y;
    cin>>x>>y;
    ll n=(2*y-x)/3;
    ll m=y-2*n;
    if((2*y-x)%3){
        cout << "0" << endl;
        return 0;
    }
    ll ans = COM(n+m,min(n,m));
    cout << ans << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    vi cnt(n);
    int now = 0, roop = 0;
    ll step = 0;
    bool isroop = false;
    while (k) {
        if (roop==0 && cnt[now]>0) {
            roop = step - cnt[now];
            k %= roop;
            isroop = true;
            continue;
        }
        if (!isroop) cnt[now] = step;
        now = a[now];
        ++step; --k;
    }
    cout << now+1 << endl;
    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

int main() {

	ll m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 != m2) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}

	return 0;
}


Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  
  vector<int> water;
  for (int i = 0; i <= f/(100*a); i++) {
    for (int j = 0; j <= f/(100*b); j++) {
      if (i == 0 && j == 0) {
        continue;
      }
      if (100*a*i +100*b*j > f) {
        break;
      }
      water.push_back(100*a*i + 100*b*j);
    }
  }
  
  vector<int> sugar;
  for (int i = 0; i <= (f/100)*e/c; i++) {
    for (int j = 0; j <= (f/100)*e/d; j++) {
      sugar.push_back(i*c + j*d);
    }
  }
  double max_con = -1, con;
  int max_water, max_sugar;
  
  for (double x : water) {
    for (double y : sugar) {
      if (x+y > f || y > (x/100)*e) continue;
      con = y/(x+y);
      if (con > max_con) {
        max_con = con;
        max_water = x;
        max_sugar = y;
      }
    }
  }
  printf("%d %d", max_water+max_sugar, max_sugar);
}

Measured memory_bytes: 2420
N, M, X = map(int, input().split())
A=list(map(int, input().split()))

N_more_count =0
N_less_count =0

for i in range (M):
    AM = int(A[i])
    if AM>X:
        N_more_count=N_more_count+1
    if AM<X:
        N_less_count=N_less_count+1
print(min(N_less_count,N_more_count))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	double res = 0;
	for (int i = 1; i <= N; i++) {
		int t = i;
		double a = 1;
		while (t < K) {
			t *= 2;
			a *= 0.5;
		}
		res += a;
	}
	res /= N;
	cout << fixed << setprecision(15) << res << endl;
}

Measured memory_bytes: 256
N, T = gets.strip.split(/ /).collect{|n| n.to_i}
a_list = gets.strip.split(/ /).collect{|n| n.to_i}

max_count = 0
max_gain = 0

min_price = a_list.shift

a_list.each{|price|
	if min_price > price
		min_price = price
	else
		gain = price - min_price
		if gain == max_gain
			max_count += 1
		elsif gain > max_gain
			max_count = 1
			max_gain = gain
		end
	end
}

puts max_count


Measured memory_bytes: 9476
def calc(s,char):
  cnt=0
  while s.count(char)<len(s):
    t=""
    for i in range(len(s)-1):
      if char in s[i:i+2]:
        t+=char
      else:
        t+="0"
    s=t
    cnt+=1
  return cnt

s=input()
ans=100
for i in range(26):
  char=chr(ord('a')+i)
  ans=min(ans,calc(s,char))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S, T;
	cin >> S >> T;
	int sum1[100010] = { 0 };
	int sum2[100010] = { 0 };

	eFOR(i, 1, S.size()) {
		if (S[i-1] == 'A')sum1[i] = sum1[i - 1] + 1;
		else sum1[i] = sum1[i - 1] + 2;
		//cout << sum1[i] << " ";
	}
	//cout << endl;
	eFOR(i, 1, T.size()) {
		if (T[i-1] == 'A')sum2[i] = sum2[i - 1] + 1;
		else sum2[i] = sum2[i - 1] + 2;
		//cout << sum2[i] << " ";
	}
	//cout << endl;

	int q;
	cin >> q;
	while (q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; c--;
		//cout << sum1[b] <<" "<< sum1[a] << " " << sum2[d] <<" "<< sum2[c] << endl;
		if ((sum1[b] - sum1[a]) % 3 == (sum2[d] - sum2[c]) % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 2512
# -*- coding: utf-8 -*-

def solve():
    N, M = map(int, input().split())
    F = [list() for _ in range(N+1)]
    D = [int() for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        D[a] += 1
        D[b] += 1
        F[a].append(b)
        F[b].append(a)

    E = [0 for _ in range(7)]
    X = list()
    for a,d in enumerate(D[1:], start=1):
        if d%2==0:
            if d >= 6:
                E[6] += 1
            elif d == 4:
                E[4] += 1
                X.append(a)
            else:
                E[d] += 1
        else:
            return 'No'
            E[1] += 1

    if E[6]>0 or E[4]>2:
        return 'Yes'

    elif E[4]<2:
        return 'No'

    else:
        x, y = X
        q = set((y,))
        R = set((x,))
        while q:
            z = q.pop()
            R.add(z)
            q |= set(F[z])-R
        if set(F[x])&R == set(F[x]):
            return 'No'
        else:
            return 'Yes'

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 28704
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}
bool func(int n,int m){
    vec a(n),b(n);
    rep(i,m){
        int x=in()-1,y=in()-1;
        a[min(x,y)]++;
        b[max(x,y)]++;
    }
    rep(i,n-1) if((a[i]-b[i])%2!=0)return false;
    return true;
}
int main(){
    int n=in(),m=in();
    string ans=func(n,m)?"YES":"NO";
    cout<<ans<<endl;
}

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

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> dist(n,0);
    int d=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            //d = min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)));
            d = min(abs(j-i),abs(x-i)+1+abs(j-y));
            dist[d]++;
        }
    }
    for(int i=1;i<n;i++){
        cout << dist[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
int a[3005];
int dp[3005][3005];
int mod = 998244353;
int add(int a , int b)
{
	return (a + b) % mod;
}
int mult(int a,  int b)
{
	return a * (ll)b % mod;
}
void Add(int &a , int b)
{
	a = add(a , b);
}
int main()
{
	int n , s;
	cin >> n >> s;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(i)
		{
			for(int j = 1; j <= s - a[i]; j++)
				Add(dp[i][j + a[i]] , dp[i - 1][j]);
			for(int j = 1; j <= s; j++)
				Add(dp[i][j] , dp[i - 1][j]);
		}
		Add(dp[i][a[i]] , i + 1);
		Add(ans , dp[i][s]);
	}
	cout << ans;
}


Measured memory_bytes: 35456
import numpy as np
import math
n,d = map(int,input().split())
A =np.array([list(map(int,input().split())) for _ in range(n)])
ans =0
for i in range(n):
    for j in range(i+1,n):
        B = np.array(A[i] - A[j])
        if math.sqrt(sum(np.square(B))) == -1*(math.sqrt(sum(np.square(B))) //-1):
            ans += 1
print(ans)

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

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

    int ans = 9 -(x - 200) / 200;
    cout << ans << endl;

}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<map>
#include<queue>
using namespace std;
const int INF = 1 << 30;
int bfs(const string& str){
  const int dy[] = { 0, 1, 1, 1}, dx[] = { 1, -1, 0, 1}, d[] = { 1, 3, 4, 5};
  queue< string > que;
  map< string , bool > used;
  int ret = INF;
  que.push(str);
  while(!que.empty()){
    string s = que.front();
    que.pop();
    ret = min<int>( ret, s.size());
    if(s.empty()) return ret;
    if(used[s]++) continue;
    for(int i = 0, y = 0; i < s.size(); i += 4, y++){
      for(int x = 0; x < 4 && i + x < s.size(); x++){
        for(int j = 0; j < 4; j++){
          int ny = y + dy[j], nx = x + dx[j];
          if( nx < 0 || nx >= 4) continue;
          if( i + x + d[j] >= s.size()) break;
          if( s[i + x] == s[i + x + d[j]]){
            string next = s;
            next.erase(next.begin() + i + x);
            next.erase(next.begin() + i + x + d[j] - 1);
            que.push(next);
          }
        }
      }
    }
  }
  return ret;
}
int main(){
  int n;
  cin >> n;
  while(n--){
    string res;
    for(int i = 0; i < 20; i++){
      char c;
      cin >> c;
      res += c;
    }
    cout << bfs(res) << endl;
  }
}

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

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

  int start,end;
  start = max(X-K+1, -1000000);
  end = min(X+K-1, 1000000);
  for (int i=start; i<=end; ++i) {
    cout << i;
    if (i!=end) cout << " ";
  }
  cout << "\n";

  return 0;
}


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

int N;
int H[100001];
int dp[100001];

int main() {
    cin >> N;
    rep(i, N) cin >> H[i];
    dp[0] = 0;
    dp[1] = abs(H[1] - H[0]);
    for (int i = 2; i < N; i ++) {
        dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]),
                    dp[i-1] + abs(H[i] - H[i-1]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)


int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(char c : s){
    if(c == '+'){
      cnt++;
    }
    else{
      cnt--;
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
 class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double px,py,r;
		for(int i=0;i<n;i++){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			px=((2*(y2-y1))*(x1*x1-x3*x3+y1*y1-y3*y3)-(2*(y3-y1))*(x1*x1-x2*x2+y1*y1-y2*y2))/((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
			py=((x1*x1-x2*x2+y1*y1-y2*y2)*(2*(x3-x1))-(x1*x1-x3*x3+y1*y1-y3*y3)*(2*(x2-x1)))/((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
			r=Math.sqrt((x1-px)*(x1-px)+(y1-py)*(y1-py));
			System.out.printf("%.3f %.3f %.3f\n",px,py,r);
		}
	}
}

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

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  if (std::abs(c - a) <= d) {
    std::cout << "Yes" << std::endl;
  } else if (std::abs(b - a) <= d && std::abs(c - b) <= d) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


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

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

  int r1=0, r4=0;
  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    if(x%2==1)r1++;
    if(x%4==0)r4++;
  }

  if(r1<=r4)cout<<"Yes"<<endl;
  else if(r1-1==r4 && r1+r4==n)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (S == U) {
    cout << A - 1 << " " << B << endl;
  }
  else {
    cout << A << " " << B - 1 << endl;
  } 
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
    string s;
    int a;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
    }
    else{
        cout<<"red"<<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long int  gcd(long long int a,long long int b){
if(b==0)
  return a;
  return gcd(b,a%b);
}
int main(){
  long long int a,b;
  cin>>a>>b;
  
  cout<<(a*b)/gcd(a,b)<<endl;
}

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int, int> P;

int board[100][100];
int num[100][100];
int m = 50;
map<P, int> memo;

void calc(int t, int f, int x, int y) {
  P p = P(t,f);
  bool flag = false;
  for (int i = 6; i > 3 and !flag; i--) {
    if (f == i and board[x][y] > board[x][y-1]) {
      flag = true;
      calc(7-i, t, x, y-1);
    } else if (f == 7-i and board[x][y] > board[x][y+1]) {
      flag = true;
      calc(7-i, 7-t, x, y+1);
    } else if (memo[p] == i and board[x][y] > board[x+1][y]) {
      flag = true;
      calc(7-i, f, x+1, y);
    } else if (memo[p] == 7-i and board[x][y] > board[x-1][y]) {
      flag = true;
      calc(7-i, f, x-1, y);
    } 
  }
  if(!flag) {
    board[x][y]++;
    num[x][y] = t;
  }
}

int main() {
  memo[P(1,2)] = 3;
  memo[P(1,3)] = 5;
  memo[P(1,4)] = 2;
  memo[P(1,5)] = 4;
  memo[P(2,1)] = 4;
  memo[P(2,3)] = 1;
  memo[P(2,4)] = 6;
  memo[P(2,6)] = 3;
  memo[P(3,1)] = 2;
  memo[P(3,2)] = 6;
  memo[P(3,5)] = 1;
  memo[P(3,6)] = 5;
  memo[P(4,1)] = 5;
  memo[P(4,2)] = 1;
  memo[P(4,5)] = 6;
  memo[P(4,6)] = 2;
  memo[P(5,1)] = 3;
  memo[P(5,3)] = 6;
  memo[P(5,4)] = 1;
  memo[P(5,6)] = 4;
  memo[P(6,2)] = 4;
  memo[P(6,3)] = 2;
  memo[P(6,4)] = 5;
  memo[P(6,5)] = 3;
  while (true) {
    int n;
    cin >> n;
    if(!n) break;
    for (int i = 0; i < 100; i++)
      for (int j = 0; j < 100; j++) {
	board[i][j] = 0;
	num[i][j] = 0;
      }
    
    for (int i = 0; i < n; i++) {
      int t, f;
      cin >> t >> f;
      calc(t, f, m, m);
    }
    int res[7] = {};
    for (int i = 0; i < 100; i++) {
      for (int j = 0; j < 100; j++) {
	res[num[i][j]]++;
      }
    }
    for (int i = 1; i < 6; i++)
      cout << res[i] << " ";
    cout << res[6] << endl;
  }
}

Measured memory_bytes: 1272
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AFallingAsleep {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<string> s(n);
      vector<int> t(n);
      rep(i, n) {
        cin >> s[i] >> t[i];
      }
      string x; cin >> x;

      bool flag = false;
      int ans = 0;
      rep(i, n) {
        if (flag) {
          ans += t[i];
        }
        if (x == s[i]) {
          flag = true;
        }
      }
      cout << ans << endl;

    }
};

signed main() {
  AFallingAsleep solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct 
{
  char mark;
  int number;
}card;

void bubblesort(card*,int);
void selectionsort(card*,card*,int);

int main(){
  int n,i,j,t;
   card detail[36],detail2[36];
  char a;
  

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    {
    scanf(" %c%c",&detail[i].mark,&a);
    detail[i].number = atoi(&a);
  }

  for(i=0; i<n; i++)
  detail2[i]=detail[i];
  bubblesort(detail,n);
  selectionsort(detail,detail2,n);
  return 0;
}
  

void bubblesort(card a[],int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j].number<a[j-1].number){
	tmp=a[j];  //swap
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a[i].mark,a[i].number);
  }

  printf("\n");
  printf("Stable\n");    
}


void  selectionsort(card a[],card a2[],int n){
  int i,j,minj,count=0;
  card tmp;
  for(i=0; i<=n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a2[j].number<a2[minj].number){
	minj=j;
      }
    }
    tmp=a2[i]; //swap
    a2[i]=a2[minj];
    a2[minj]=tmp;
}
  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a2[i].mark,a2[i].number);
  }
  printf("\n");

  
  for(i=0;i<n;i++){
    if(a[i].mark != a2[i].mark || a[i].number != a2[i].number){
      printf("Not stable\n");
      count=1;
      break;
    } }
  
  if(count != 1) printf("Stable\n");
  
}

 



Measured memory_bytes: 2048
#include<stdio.h>
#define B 100
main()
{
  int N;//要素
  int A[B];//配列
  int i,n,j,temp=0,num=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<(N-1);i++)
    {
      for(j=(N-1);j>i;j--)
	{
	  if(A[j-1]>A[j])
	    {
	       temp=A[j-1];
	      A[j-1]=A[j];
	      A[j]=temp;
	      num++;
	    }
	}
    }
    
 for(i=0;i<N-1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d\n",A[N-1]);
 printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 600
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()

print(max(n - sum(a), -1))

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int d[55];
vector<P> a;
bool used[101];

bool ok(int x){
  int i=0;
  int crth=0;
  int cnt=1;
  memset(used,0,sizeof(used));
  used[0]=true;
  while(1){
    while(i<a.size()&&(a[i].fi-crth<x||used[a[i].se]))i++;
    if(i==a.size())return false;
    used[a[i].se]=true;
    cnt++;
    if(cnt==n+1){
      if(min(a[i].fi,24-a[i].fi)>=x)return true;
      else return false;
    }
    crth=a[i].fi;
  }
  return false;
}

int main(){
	cin>>n;
  rep(i,n){
    cin>>d[i];
    if(d[i]==0||d[i]==12){
      a.push_back(P(d[i],i+1));
    }else{
      a.push_back(P(d[i],i+1));
      a.push_back(P(24-d[i],i+1));
    }
  }
  a.push_back(P(0,0));
  sort(all(a));
  rep(x,51){
    if(!ok(x)){
      cout<<x-1<<endl;
      return 0;
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

ll N;
ll A[210000];

int main(void){

    cin >> N;
    for (int i = 1; i <= N;i++) cin >> A[i];

    ll ans = 0;

    ll limit = 0;
    A[0] = 0;

    for (int i = 1; i <= N;i++){
        if (limit <= A[i]){
            limit = A[i];
        } else {
            ans += limit - A[i];
        }
    }


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


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

typedef long long ll;

int main(){

    string s;
    cin >> s;
    set<std::string> se = {"a","i","u","e","o"};
    if (se.count(s) > 0) {
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int ans = t/a * b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int deg[5];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(int i=1;i<4;i++)
	{
		int a,b;
		cin>>a>>b;
		deg[a]++;
		deg[b]++;
		if(deg[a] == 3 || deg[b] == 3)
		{
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define incm(x,y) {x=((x)+(y))%mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
const double pi=acos(-1);
int n,m,i,j;
double ansx,ansy,ways,a[200005];
int main()
{
	cin>>n>>m;
	fz1(i,n){
		cin>>a[i];
	}
	fz1(i,n)fz(j,i+1,n){
		ansx+=cos(pi*(a[i]+a[j])/m)*(n-(j-i+1));
		ansy+=sin(pi*(a[i]+a[j])/m)*(n-(j-i+1));
		ansx+=cos(pi*(a[i]+a[j]+m)/m)*((j-i-1));
		ansy+=sin(pi*(a[i]+a[j]+m)/m)*((j-i-1));
	}
	ways=1.0*n*(n-1)*(n-2)/6;
	printf("%.10lf %.10lf\n",ansx/ways,ansy/ways);
	return 0;
}

Measured memory_bytes: 4156
import sys
sys.setrecursionlimit(10000000)
rd = sys.stdin.buffer.read
rl = sys.stdin.buffer.readline
NIL = -1

class Node:
    def __init__(self, left, right, p):
        self.left = left
        self.right = right 
        self.p = p

n = int(input())
T = [Node(NIL, NIL, NIL) for _ in range(n)]
for _ in range(n):
    x, y, z = map(int ,input().split())
    T[x].left = y
    T[x].right = z
    if y != NIL:
        T[y].p = x
    if z != NIL:
        T[z].p = x

#rootを見つける
def searchRoot():
    for node_i in range(n):
        if T[node_i].p == NIL:
            return node_i

preorder_res = []
def preorder(node_i):
    if node_i == NIL:
        return
    preorder_res.append(node_i)
    preorder(T[node_i].left)
    preorder(T[node_i].right)

inorder_res = []
def inorder(node_i):
    if node_i == NIL:
        return
    inorder(T[node_i].left)
    inorder_res.append(node_i)
    inorder(T[node_i].right)

postorder_res = []
def postorder(node_i):
    if node_i == NIL:
        return
    postorder(T[node_i].left)
    postorder(T[node_i].right)
    postorder_res.append(node_i)

def outPut(s, array):
    n = len(array)
    print(s)
    res =' '
    for i in range(len(array)):
        if i==n-1:
            res += str(array[i])
        else:
            res += str(array[i])+' ' 
    print(res)


def main():
    s = ['Preorder', 'Inorder', 'Postorder']
    l = [preorder_res, inorder_res, postorder_res]
    root = searchRoot()
    preorder(root)
    inorder(root)
    postorder(root)

    for i, j in zip(s, l):
        outPut(i, j)
if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int n,p=1,c=1,tmp;
  cin >> n;
  REP(i,n){
    cin >> tmp;
    p*=3;
    tmp%2?0:c*=2;
  }
  cout << p-c << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a[3][3];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	bool c[3][3] = {};
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < n; k++)
				if (v[k] == a[i][j])
					c[i][j] = true;
	bool bingo = false;
	for (int i = 0; i < 3; i++)
		if (c[i][0] && c[i][1] && c[i][2])
			bingo = true;
	for (int i = 0; i < 3; i++)
		if (c[0][i] && c[1][i] && c[2][i])
			bingo = true;
	if (c[0][0] && c[1][1] && c[2][2])
		bingo = true;
	if (c[0][2] && c[1][1] && c[2][0])
		bingo = true;
	if (bingo) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    long long l, r;
    int ans = 2019;
    cin >> l >> r;

    vector<bool> a(2019, false);
    if (r - l < 2019)
    {
        for (int i = l; i <= r; i++)
            a[i % 2019] = true;
    }
    else
    {
        for (int i = 0; i < 2019; i++)
            a[i] = true;
    }
    for (int i = 0; i < 2019; i++)
    {
        for (int j = i + 1; j < 2019; j++)
        {
            if (a[i] && a[j])
                ans = min(ans, (i * j) % 2019);
        }
    }

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

Measured memory_bytes: 256
package main

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

const N = 1000000007

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	cntZeroZero := 0
	battles := make(map[PairInt][]int)

	for i := 0; i < n; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		ra, rb := Ratio(a, b)
		if ra == 0 && rb == 0 {
			cntZeroZero++
			continue
		}

		if rb <= 0 {
			ra, rb = ReverseRatio(ra, rb)
			pair := PairInt{ra, rb}
			_, exists := battles[pair]
			if !exists {
				battles[pair] = make([]int, 2)
			}
			battles[pair][1]++
		} else {
			pair := PairInt{ra, rb}
			_, exists := battles[pair]
			if !exists {
				battles[pair] = make([]int, 2)
			}
			battles[pair][0]++
		}
	}

	cnt := 1
	for _, battle := range battles {
		cntSub := Pow(2, uint(battle[0])) + Pow(2, uint(battle[1])) - 1
		cnt = cnt * cntSub % N
	}

	cnt = (cnt + cntZeroZero - 1) % N
  	cnt = cnt + N
    cnt = cnt % N

	fmt.Println(cnt)
}

type PairInt struct {
	A int
	B int
}

// util
// *   math/simple

func Ratio(x, y int) (int, int) {
	if x == 0 {
		if y == 0 {
			return 0, 0
		}
		return 0, 1
	} else if y == 0 {
		return 1, 0
	}

	sign := 1
	if x > 0 && y < 0 {
		sign = -1
	} else if x < 0 && y > 0 {
		sign = -1
	}

	x = Abs(x)
	y = Abs(y)
	var small, big int
	if x < y {
		small, big = x, y
	} else {
		small, big = y, x
	}
	gcd := GCD(small, big)
	return x / gcd, sign * y / gcd
}

func ReverseRatio(x, y int) (int, int) {
	sign := -1
	if x == 0 || y <= 0 {
		sign = 1
	}

	return Abs(y), sign * Abs(x)
}

func GCD(smaller, bigger int) int {
	rem := bigger % smaller
	if rem == 0 {
		return smaller
	}
	return GCD(rem, smaller)
}

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer = answer * base % N
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 31136
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,ground,ou,point;
  string s;
  
  scanf("%d",&n);
  
  for(int cas=0;cas<n;cas++){
    ground = ou = point = 0;
    while(1){
      cin >> s;
      if(s == "OUT"){
	ou++;
	if(ou == 3) break;
      } else if(s == "HIT"){
	ground<<=1;
	ground|=1;
	if(ground >= (1<<3)){
	  ground&=(~(1<<3));
	  point++;
	}
      } else{
	for(int i=0;i<3;i++){
	  if(ground&(1<<i)) point++;
	}
	ground=0;
	point++;
      }
    }
    cout << point << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>    
#define pb push_back
 
#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
 
typedef long long ll;
using namespace std;
 
typedef pair<int,int> ii;
typedef vector<int> vi;
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}
 
int main(){
	//freopen("a.in","r",stdin);
	string s;
	cin>>s;
	ll n,sum = 0;
	cin>>n;
	
	vi v;
	
	int i = 0,j,l = s.size();
	while(i<l){
		j = i;
		while(j<l && s[i] == s[j]) j++;
		v.pb(j-i);
		i = j;
	}
	
	F0R(i,1,v.size()-1)
		sum += ll(v[i]/2) * n;
	
	if(v.size()==1){
		sum = (n*ll(s.size()))/2;
	} else if(s[0] == s[s.size()-1]){
		sum += (n-1)*((v[0] + v[v.size()-1])/2);
		sum += v[0]/2;
		sum += v[v.size()-1]/2;
 	} else {
		sum += n*((v[0]/2) + (v[v.size()-1])/2);
	}
	
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    if(s==t.erase(t.size()-1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

  int X, Y, Z;
  std::cin >> X >> Y >> Z;

  std::swap(X, Y);
  std::swap(X, Z);

  std::cout << X << " " << Y << " " << Z << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((a > 9 || b > 9) ? -1 : a*b);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

int main() {
    int sum = 0, b = 0, w = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'W'){
            w++;
        }else{
            b++;
        }
    }
    if(w == s.size() || b == s.size()){
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < s.size() - 1; i++){
        if (s[i] == 'W'){
            if (s[i + 1] == 'B'){
                sum++;
            }
        }
        if (s[i] == 'B'){
            if (s[i + 1] == 'W'){
                sum++;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int n, m, p, an, bn;
long long ans, g, ag, bg;
int x[100000];
int y[100000];
int a[100000];
int b[100000];
long long eans[100000];
int root(int c) {
	int t = 0;
	while (x[c] >= 0) {
		y[t] = c;
		c = x[c];
		t++;
	}
	for (int i = 0; i < t - 1; i++) {
		x[y[i]] = c;
	}
	return c;
}
void merge(int c, int d) {
	if (c == d)return;
	if (x[c] < x[d]) {
		x[c] += x[d];
		x[d] = c;
	}
	else if (x[c] == x[d]) {
		x[c] += x[d];
		x[d] = c;
	}
	else{
		x[d] += x[c];
		x[c] = d;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", a + i, b + i);
		a[i]--, b[i]--;
	}
	g = n;
	ans = g * (g - 1) / 2;
	for (int i = 0; i < n; i++)x[i] = -1;
	for (int i = m - 1; i >= 0; i--) {
		eans[i] = ans;
		an = root(a[i]);
		bn = root(b[i]);
		if (an != bn) {
			ag = x[an];
			bg = x[bn];
			ans -= ag * bg;
			merge(an, bn);
		}
	}
	for (int i = 0; i < m; i++) {
		printf("%lld\n", eans[i]);
	}
}

Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
#include<map>
using namespace std;

int main() {
	int a, b;

	while (cin >> a >> b) {
		cout << (int)log10(a + b) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/

int main()
{
  string s;cin>>s;
  string ans= s[0]==s[1] && s[0]==s[2] ? "No":"Yes";
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

double W, H, x, y;

double s, s2;

int main(void){
	cin>>W>>H>>x>>y;

	s = W * H / 2;

	printf("%.12f ", s);
	if (2 * x == W && 2 * y == H) printf("%c\n", '1');
	else printf("%c\n", '0');
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
#define int(x) int x; scanf("%d",&x)
#define input(x) scanf("%d",&x)
#define rep(x,n) for(int x = 0; x < n; x++)
#define _br printf("\n")
#define INF 2000000000

bool complete[100];
int d[100];

int rec_msp(int n, int Path[][100]){
    int moP = 0;
    rep(i,n){
        complete[i] = false;
        d[i] = INF;
    }
    d[0] = 0;
    int num = 0;
    
    
    while (num != n) {
    
        int mind = INF;
        int mindi = 0;
        rep(i,n){
            if (mind > d[i] && !complete[i]) {
                mind = d[i];
                mindi = i;
            }
        }
        
        complete[mindi] = true;
        num++;
        
        //update d[] with mindi.
        
        rep(i,n){
            if (Path[mindi][i] != -1 && d[i] > Path[mindi][i] && !complete[i]) {
                d[i] = Path[mindi][i];
            }
        }
        
    }
    
    int sum = 0;
    rep(i,n) sum += d[i];
    
    return sum;
}

int main(){
    int(n);
    int Path[100][100];
    rep(r,n){
        rep(c,n) input(Path[r][c]);
    }
    
    printf("%d\n",rec_msp(n,Path));
    
    return 0;
}

Measured memory_bytes: 1228