akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, h, w;
  cin>>n>>h>>w;

  cout<<(n-h+1)*(n-w+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


string Main(int H, int N, VI &A)
{
    sort(RALL(A));
    ll sum = 0;
    ll HH = (ll)H;
    REP(i, N) {
        sum += A[i];
        if(sum >= HH) return "Yes";
    }
    return "No";
}

int main(void){
    int H, N;
    cin >> H >> N;
    VI A(N);
    REP(i, N) cin >> A[i];
    cout << Main(H, N, A) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    SRT(a,n);
    REV(a,n);
    int cnt=0,ans=0;
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            cnt+=a[i];
        }
        else
        {
            ans+=a[i];
        }
    }
    cout<<cnt-ans<<NL;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);

		String S = in.readLine();
		Set<Character> numbers = new HashSet<>();
		for (int i = 0; i < 10; ++i) {
			numbers.add(Integer.toString(i).charAt(0));
		}
		
		boolean valid = isValid(S, numbers, A);
		String str = valid? "Yes": "No";
		System.out.println(str);

	}

	static boolean isValid(String S, Set<Character> numbers, int A) {
		for(int i = 0; i < S.length(); ++i) {
			if(i == A) {
				if(S.charAt(i) != '-') {
					return false;
				}
			}else {
				if(!numbers.contains(S.charAt(i))) {
					return false;
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 23252
import sys


try:
    sys.stdin = open(sys.path[0] + '\\input.txt', 'r')
    sys.stdout = open(sys.path[0] + '\\output.txt', 'w')
except FileNotFoundError:
    pass



def solve():
    s, w = list(map(int, input().split()))

    if w >= s:
        print('unsafe')
    else:
        print('safe')

solve()


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

struct info {
    string name;
    int s, e;
    info(string _name, int by, int wy) {
        name = _name;
        s = wy - by;
        e = wy;
    }
    bool operator<(const info& another) { 
        return s < another.s;
    }
};

int main() {
    int n, q;
    while (cin >> n >> q, n | q) {
        vector<info> v;
        for (int i = 0; i < n; i++) {
            string s;
            int by, wy;
            cin >> s >> by >> wy;
            v.push_back(info(s, by, wy));
        }
        sort(v.begin(), v.end());
        for (int i = 0; i < q; i++) {
            int y, f = 1;
            cin >> y;
            for(int i = 0; i < v.size(); i++){
                if(v[i].s < y && y <= v[i].e){
                    cout << v[i].name << " " << y - v[i].s << endl;
                    f = 0;
                    break;
                }
            }
            if(f) cout << "Unknown" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;

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

	ll N;
	cin >> N;

	vector<ll> A(N);
	rep(i,N){
		cin >> A[i];
	}

	ll odd = 0, even = 0;
	ll two_pow =1;

	rep(d,60){
		odd = 0;
		even = 0;
		rep(i,N){
			if(A[i] & (1LL << d)) odd++;
			else even++;
		}
		ll add = (odd * even) % MOD * two_pow % MOD;
		ans = (ans + add) % MOD;
		two_pow = (two_pow * 2) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            long sum = 0;
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            if (sum < k) {
                System.out.println(n);
                return;
            }
            Arrays.sort(a);
            for (int i = 0; i < n; ++i) {
                if (a[i] >= k) {
                    a = Arrays.copyOf(a, i);
                    break;
                }
            }
            int min = -1, max = a.length;
            while (max - min > 1) {
                int mid = (max + min) / 2;
                if (ok(a, mid, k)) max = mid;
                else min = mid;
            }
            System.out.println(max);
        }
    }

    boolean ok(int a[], int b, int k) {
        boolean ok[] = new boolean[k];
        ok[0] = true;
        for (int i = 0; i < a.length; ++i) {
            if (i == b) continue;
            for (int j = k - 1 - a[i]; j >= 0; --j) {
                if (ok[j]) ok[j + a[i]] = true;
            }
        }
        for (int i = k - a[b]; i < k; ++i) {
            if (ok[i]) return true;
        }
        return false;
    }

    void tr(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}


Measured memory_bytes: 29208
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    int n;
    cin >> n;
    if(n%1000==0){
        cout << 0 << endl;
    }else{
        cout << 1000-n%1000 << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n; cin >> n;
  map<int, int> d;
  rep(i, n) {
    int x; cin >> x;
    ++d[x];
  }
  int m; cin >> m;
  map<int, int> t;
  rep(i, m) {
    int x; cin >> x;
    ++t[x];
  }
  for(auto x : t) {
    if(d[x.first] < x.second) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 22208
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/* ======IO====== */
var (
	InputString func() string
)

func init() {
	InputString = newInputString(os.Stdin)
}

func newInputString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("error scan")
		}
		return r.Text()
	}
}

func InputInt() int {
	return int(readInt64())
}
func InputInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func InputInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func InputInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(InputString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func InputIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = InputInt()
	}
	return b
}

func InputFloat64() float64 {
	return float64(inputFloat64())
}

func inputFloat64() float64 {
	f, err := strconv.ParseFloat(InputString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func InputFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = InputFloat64()
	}
	return b
}

func InputRuneSlice() []rune {
	return []rune(InputString())
}

/* ======Math====== */
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

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

func Round(f float64) float64 {
	return math.Floor(f + .5)
}

/* ======Heap====== */

type IntHeap []int

func (h IntHeap) Len() int { return len(h) }

// default minimum heap
func (h IntHeap) Less(i, j int) bool  { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/* ======Util====== */

func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic("strtoi error")
	} else {
		return i
	}
}

//
//type sortable [][]int
//
//func (s sortable) Len() int { return len(s) }
//
//func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }
//
//func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	N, M := InputInt2()
	As := InputIntSlice(N)
	mh := &IntHeap{}
	heap.Init(mh)
	for _, a := range As {
		heap.Push(mh, a)
	}

	for i := 0; i < M; i++ {
		t := heap.Pop(mh)
		a := int(t.(int) / 2)
		heap.Push(mh, a)
	}

	sum := 0
	for i := 0; i < N; i++ {
		sum += heap.Pop(mh).(int)
	}
	fmt.Print(sum)
}


Measured memory_bytes: 8576
//update 2009/6/21
// uva accept 218.11626,681
#include<iostream>
#include<complex>
#include<algorithm>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)


typedef complex<double> P;
//typedef complex<int> P;
const double eps = 1e-10;
#define SIZE N

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}
//ê¼üÌf[^ðÈ­Í<0,È«½­È¢Í<=0É·éÆ¢¢B
int ccw(P a,P b){
    if ( cross(a,b) <0)return 1;
    else return -1;
}
bool cmp(const P&a,const P&b){
  if ( a.real() != b.real())return a.real()<b.real();
  else return a.imag() < b.imag();
}

void ConvexHull(int n,P *inp,P *out,int &p){
  sort(inp,inp+n,cmp);
  bool used[n];
  int num[n];
  fill(used,used+n,false);
  p=0;
  out[p++]=inp[0];out[p++]=inp[1];
  used[1]=true;
  num[0]=0;num[1]=1;
  for(int i=2;i<n;i++){//upper bound
    while(p>=2){
      if ( ccw(out[p-1]-out[p-2],inp[i]-out[p-2]) ==1)break;
      else {
	used[num[p-1]]=false;
	p--;
      }
    }
    num[p]=i;
    used[i]=true;
    out[p++]=inp[i];
  }
  for(int i=n-2,t=p+1;i>=0;i--){
    if ( used[i] == true)continue;
    while(p>=t){//·ÅÉÊïÉÈÁ½_ðÁ³È¢æ¤É·éB
      if ( ccw(out[p-1]-out[p-2],inp[i]-out[p-2]) ==1)break;
      else p--;
    }
    out[p++]=inp[i];
  }
  return;
}

bool isp(P a,P b,P c){
  return abs(a-c)+abs(b-c) < abs(a-b)+eps;
}

bool is_in(int n,P* in,P a){
  int cnt =0;
  rep(i,n){
    P cur = in[i]-a,next=in[(i+1)%n]-a;
    if (cur.imag() > next.imag())swap(cur,next);
    if (cur.imag()<0 && 0<=next.imag() &&
	cross(next,cur)>=0)cnt++;
    if (isp(in[i],in[(i+1)%n],a))return true;
  }

  if (cnt %2 == 1)return true;
  else return false;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  if ( isp(a1,a2,b1))return true;
  if ( isp(a1,a2,b2))return true;
  if ( isp(b1,b2,a1))return true;
  if ( isp(b1,b2,a2))return true;
  if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<-eps ) && 
	( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-eps))return true;
  else return false;
}


bool solve(int n,P *in,int m,P *in2){
  rep(i,n){
    if (is_in(m,in2,in[i]))return false;
  }
  
  rep(i,m){
    if (is_in(n,in,in2[i]))return false;
  }

  rep(i,n){
    rep(j,m){
      if (is_intersected_ls(in[i],in[(i+1)%n],in2[j],in2[(j+1)%m]))
	return false;
    }
  }



  return true;
}

main(){
  int n,m;
  P in[200],in2[200],gon[200],gon2[200];
  while(cin>>n>>m &&n){
    rep(i,n)cin>>in[i].real()>>in[i].imag();
    rep(i,m)cin>>in2[i].real()>>in2[i].imag();

    int nn=0,mm=0;
    ConvexHull(n, in,gon, nn);
    ConvexHull(m,in2,gon2,mm);
    if (solve(nn,gon,mm,gon2))puts("YES");
    else puts("NO");

  }
}

Measured memory_bytes: 960
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

bool isRightTriangleCore(int a, int b, int c)
{
  return a * a + b * b == c * c;
}

bool isRightTriangle(int a, int b, int c)
{
  int ret = false;

  ret |= isRightTriangleCore(a, b, c);
  ret |= isRightTriangleCore(c, a, b);
  ret |= isRightTriangleCore(b, c, a);

  return ret;
}

int main(void)
{
  int n;

  std::cin >> n;

  while (n--) {
    int a, b, c;

    std::cin >> a >> b >> c;

    if (isRightTriangle(a, b, c)) {
      std::cout << "YES" << std::endl;
    }
    else {
      std::cout << "NO" << std::endl;
    }
  }

  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n, m, v, p; cin >> n >> m >> v >> p;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    long long sum = a[p-1];
    long long ans = p;
    for (long long i = p; i < n; i++) {
        long long remain = sum - a[i] * (i-p+1);
        long long cnt = i - p + 1;
        long long diff = min(cnt, n-v);
        if ((diff * m >= remain) && (a[p-1] - a[i]) <= m) ans++;
        sum += a[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
//Target for Pupil
//Implementation and Data structures
//Prodip sarker(student_ip)
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define al(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
	int a,b,c,n,i,t,tmp,d,e,f,p;
	cin>>t;
	int cnt=0,k=0;
	p=0;
	while(t--)
	{
		cin>>a>>b;
		if(a==b&&k==1){
		k=1;
		cnt++;
	}
	else if(a==b&&k==0)
	{
		
		cnt=1;
		k=1;
	}
	else
	{
		k=0;
		cnt=0;
	}
	if(cnt>=3)
	p=1;
		
		
	}
	if(p==1)
	cout<<"Yes\n";
	else
	cout<<"No\n";

	return 0;
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    int ans = INF;
    for(int S=0;S<1<<(h-1);S++){
        int n = 0, m = 0;
        bool valid = true;
        for(int i=0;i<h-1;i++){
            if((S>>i)&1) n++;
        }
        vector<int> cnt(n+1);
        for(int j=0;j<w;j++){
            int pi = 0;
            for(int i=0;i<h;i++){
                if(s[i][j]=='1') cnt[pi]++;
                if((S>>i)&1) pi++; 
            }
            bool over = false;
            for(auto x : cnt){
                over |= x > k;
            }
            if(over){
                m++;
                fill(cnt.begin(), cnt.end(), 0);
                int pi = 0;
                for(int i=0;i<h;i++){
                    if(s[i][j]=='1') cnt[pi]++;
                    if((S>>i)&1) pi++; 
                }
                for(auto x : cnt){
                    if(x > k){
                        valid = false;
                        break;
                    }
                }
            }
        }
        if(valid) ans = min(ans, n+m);
    }
    cout << ans << endl;
}


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 + 7LL;

int H, W;
int a, b;

const int MAX = 510000;


ll 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;
	}
}

ll 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;
}

ll ans;

int main(void){
	cin>>H>>W>>a>>b;

	COMinit();

	for (int i = b; i < W; i++) {
		ans += COM(H - a - 1 + i, i) * COM(a - 1 + W - 1 - i, a - 1);
		ans %= MOD;
	}

	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 12160
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

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

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

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

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n;
string a,b;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>a>>b;
	string c;
	for (int i=0;i<n;++i) c.pb(a[i]),c.pb(b[i]);
	cout<<c;
}





Measured memory_bytes: 896
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean flag = true;
        
        if(n < 1000){
            System.out.println("ABC");
        }else{
            System.out.println("ABD");
        }
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  string s1,s2;
  cin >> s1 >> s2;
  if(s1.size()>s2.size()){
    cout << "GREATER" << endl;
    return 0;
  }
  else if(s1.size()<s2.size()){
    cout << "LESS" << endl;
    return 0;
  }else{
    if(s1>s2){
      cout << "GREATER" << endl;
    }
    else if(s1<s2){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }
  }
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int grid[1001][1001],a,b;
ll memo[1001][1001];
const int mod=1e9+7;
ll solve(int x,int y){
    if(x==a-1 && y==b-1)
        return 1;
    if(x>=a || y>=b)
        return 0;
    ll &cur=memo[x][y];
    if(cur!=-1)
        return cur;
    cur=0;
    if(grid[x][y]=='#')
        return 0;
    cur+=solve(x+1,y)%mod+solve(x,y+1)%mod;
    return cur%mod;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(memo,-1,sizeof(memo));
    cin>>a>>b;
    for(int i=0;i<a;i++){
        string x;
        cin>>x;
        for(int c=0;c<b;c++)
            grid[i][c]=x[c];
    }
    cout<<solve(0,0)%mod;
}

Measured memory_bytes: 12032
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n");
    println(solve(input).trim());
  }

  def solve(input:String):String={
    if(input.zipWithIndex.forall{v => f(v._1, v._2)}){
      "Yes"
    }else{
      "No"
    }
  }

  def f(c:Char,i:Int):Boolean={
    if(i%2==0){
      Array('R', 'U', 'D').contains(c)
    }else{
      Array('L', 'U', 'D').contains(c)
    }
  }
}


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

const int M = 1000001;
vector<bool> L(M, false);

int main() {
    int N, k;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int ans = 0;

    for (int i = 0; i < N; i++) {
        if (!L[A[i]]) {
            if (i == N-1 || A[i] != A[i+1]) {
                ans++;
            }
            k = A[i];
            for (int k = A[i]; k < M; k += A[i]) {
                L[k] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c));

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>				//edit by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    scanf("%lld",&a)
#define sc2(a,b)    scanf("%lld%lld",&a,&b)
#define pr(a)	    printf("%lld ",a)
#define pr2(a,b)    printf("%lld %lld",a,b)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-6;	//dung trong sai so
ll const Base=1e9+7;
ll mark[1000000];

ll Solves(){
//	INPUT;
	ll n,k,cnt=0,ans=1e17,x,h,w;
	// PROCESSING IN HERE
//	sc(n);
	sc2(h,w);
	ll a,b,c;
	a=h/3;
	b=(h-a)/2;
	c=h-(a+b);
	ans=min(ans,w*max(a,max(b,c))-w*min(a,min(b,c)));
	
	a=w/3;
	b=(w-a)/2;
	c=w-(a+b);
	ans=min(ans,h*max(a,max(b,c))-h*min(a,min(b,c)));
	
	fu(i,1,h+1){
		a=i*w;
		b=(h-i)*(w/2);
		c=h*w-a-b;
		ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
	}
	
	fu(i,1,w+1){
		a=i*h;
		b=(w-i)*(h/2);
		c=h*w-a-b;
		ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
	}
	pr(ans);
	re 0;
}


int main(){
	Solves();
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  cout<<(1-n)<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(){
  long long h,w;
  cin >> h >> w;
  if(h==1 || w==1){
    cout << 1 << "\n";
    return 0;
  }
  long long x = h * w /2;
  if(h * w % 2 == 0) cout << x << "\n";
  else cout << x+1 << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define emp emplace
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 200100;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll N,Q,a,b,c,d,e,M,X;
ll A[MAXN];
ll B[MAXN];
map<ll,ll> p;
ll ans;
vi V[MAXN];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	string A;
	cin>>A;
	A[1]='B'+'R'-A[1];
	cout<<A;
}

Measured memory_bytes: 8292
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    if N % 2 == 1:
        s = N // 2
        for i in range(M):
            v = i * 2 + 1
            print(s, s + v)
            #print(s, s + v, v, N - v)
            s -= 1
    else:
        s = N // 2
        cnt = 0
        used = set()
        for i in range(M // 2 + 1):
            v = i * 2 + 1
            if v == N // 2 or v in used:
                continue
            print(s, s + v)
            #print(s, s + v, v, N - v)
            s -= 1
            cnt += 1
            used.add(v)
            used.add(N - v)
        s = 1
        for i in range(M - cnt):
            v = N - s - s
            print(s, N - s)
            #print(s, N - s, v, N - v)
            s += 1
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()

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

    ll a,b,h; Cin3(a,b,h);
    Cout((a+b)*h/2);
    return 0;
}

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

bool pal(string s)
{
    int l = 0;
    int n=s.size();
    int h = n - 1;


    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}
int main()
{

   string s,s1,s2;
   cin>>s;
   int n=s.size();
   for(int i=0;i<(n-1)/2;i++)
   {
       s1+=s[i];
   }
   int mid=(n+3)/2;
   mid--;
    for(int i=mid;i<n;i++)
   {
       s2+=s[i];
   }
   if(pal(s1) && pal(s2) && s1==s2) cout<<"Yes";
   else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	int X;
	cin >> X;

	if (X==7) {
		cout << "YES" << endl;
	} else if (X==5) {
		cout << "YES" << endl;
	} else if (X==3) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,C; cin>>N>>C;
  vii D(C,vi(C));
  vii A(3,vi(C));
  rep(i,0,C){
    rep(j,0,C){
      cin>>D[i][j];
    }
  }
  REP(i,1,N){
    REP(j,1,N){
      int X; cin>>X;
      A[(i+j)%3][X-1]++;
    }
  }
  vii B(3,vi(C));
  rep(i,0,3){
    rep(j,0,C){
      rep(k,0,C)
        B[i][j]+=A[i][k]*D[k][j];
    }
  }
  int ans=MOD;
  rep(i,0,C){
    rep(j,0,C){
      rep(k,0,C){
        if(i==j||j==k||k==i)
          continue;
        ans=min(ans,B[0][i]+B[1][j]+B[2][k]);
      }
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  char number[3];
  int i;
 
  scanf("%s" "%s" "%s", &number[0], &number[1], &number[2]);
  for(i = 0; i < 3; i++){
    if(number[i] == '7'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 1608
INF = float('inf')
mm = [(-1,-1)]
n = int(input())
for _ in range(n):
    mm.append(tuple((map(int,input().split()))))

def scala(a,b,c):
    return mm[a][0] * mm[b][1] * mm[c][1] 

dp = [[INF for _ in range(n+1)] for _ in range(n+1)]
#init
for i in range(1,n):
    dp[i][i+1] = mm[i][0] * mm[i+1][1] * mm[i][1]
    dp[i][i] = 0
dp[-1][-1] = 0
#begin dp
for d in range(2,n):
    for l in range(1,n-d+1):
        r = l + d
        for m in range(l,r):
            dp[l][r] = min(dp[l][m] + dp[m+1][r] + scala(l,r,m), dp[l][r])
print(dp[1][n])
#for i in range(n+1):
#    print(dp[i])
#for d in range(2,n):
#    for l in range(1,n-d+1):
#        r = l + d
#        for m in range(l,r):
#            dp[l][r] = max(dp[l][m] + dp[m+1][r] + scala(l,r,m), dp[l][r])

#print(dp[1][n])
#for i in range(n+1):
#    print(dp[i])



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

using namespace std;

#define NMAX 10

int main(){

	int N;
	string deck;
	vector<int> tehuda;
	int boti;

	while(1){

		cin>>N;
		if(N==0) break;

		for(int i=0;i<N;i++) tehuda.push_back(0);

		cin>>deck;
		boti=0;

		for(int i=0;i<deck.size();i++){
			if(deck[i]=='M') tehuda[i%N]++;
			else if(deck[i]=='S') boti+=tehuda[i%N]+1,tehuda[i%N]=0;
			else if(deck[i]=='L') tehuda[i%N]+=boti+1,boti=0;
		}

		sort(tehuda.begin(),tehuda.end());

		for(int i=0;i<tehuda.size();i++) cout<<tehuda[i]<<" ";
		cout<<boti<<endl;

		tehuda.clear();

	}

}

Measured memory_bytes: 1228
#include <iostream>

#include <sstream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cmath>

typedef long long ll;

const int _p=1000000007;

using namespace std;



int n,m;

int ans=0,a[200005],b[200005];



int _get(int a[],int n){

	ll ans=0;

	for (int i=1;i<=n;i++)

		ans=(ans-(ll)(n-i)*a[i]%_p)%_p;

	for (int i=1;i<=n;i++)

		ans=(ans+(ll)(i-1)*a[i]%_p)%_p;

	return (ans+_p)%_p;

}



int main(){

	

	scanf("%d%d",&n,&m);

	for (int i=1; i<=n; i++) scanf("%d",&a[i]);

	for (int i=1; i<=m; i++) scanf("%d",&b[i]);

	sort(a+1,a+n+1);

	sort(b+1,b+m+1);

	ans=(ll)_get(a,n)*_get(b,m)%_p;

	printf("%d\n",ans);

	

	return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
template<class T> inline void read(T &x){
	x=0; register char c=getchar(); register bool f=0;
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;
}
template<class T> inline void print(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10); putchar(x%10+'0');
}
template<class T> inline void print(T x,char c){print(x),putchar(c);}

const int N=1e5+10,M=400,mod=998244353;
int n,lim,max,m[3],sg[N];
std::vector<int> G[3][N];

struct z {
	int x;
	z(int x=0):x(x){}
	friend inline z operator*(z a,z b){return (long long)a.x*b.x%mod;}
	friend inline z operator-(z a,z b){return (a.x-=b.x)<0?a.x+mod:a.x;}
	friend inline z operator+(z a,z b){return (a.x+=b.x)>=mod?a.x-mod:a.x;}
}ans,pw[N],f[3][N],g[N];
inline z fpow(z a,int b){z s=1;for(;b;b>>=1,a=a*a)if(b&1)s=s*a;return s;}

void SG(int m,std::vector<int> G[N],int sg[N]){
	static bool vis[N];
	for(int i=n;i>=1;i--){
		for(int j:G[i])vis[sg[j]]=1;
		sg[i]=0;
		while(vis[sg[i]])sg[i]++;
		for(int j:G[i])vis[sg[j]]=0;
	}
}

void fwt(z *a){
	for(int len=1;len<lim;len<<=1)
		for(int i=0;i<lim;i+=(len<<1))
			for(int j=0;j<len;j++){
				z x=a[i+j],y=a[i+j+len];
				a[i+j]=x+y,a[i+j+len]=x-y;
			}
}

int main(){
#ifdef memset0
	freopen("1.in","r",stdin);
#endif
	read(n),lim=sqrt(n);
	for(int i=0;i<3;i++){
		read(m[i]);
		for(int u,v,j=1;j<=m[i];j++){
			read(u),read(v);
			// G[i][u].push_back(v);
			G[i][std::min(u,v)].push_back(std::max(u,v));
			// G[i][std::max(u,v)].push_back(std::min(u,v));
		}
	}
	pw[0]=1,pw[1]=fpow(10,18);
	for(int i=2;i<=n;i++)pw[i]=pw[i-1]*pw[1];
	for(int i=0;i<3;i++){
		SG(m[i],G[i],sg);
		for(int j=1;j<=n;j++){
			max=std::max(max,sg[j]);
			f[i][sg[j]]=f[i][sg[j]]+pw[j];
		}
		// for(int j=1;j<=n;j++){
		// 	printf("%d%c",sg[j]," \n"[j==n]);
		// }
	}
	lim=1; while(lim<=max)lim<<=1;
	for(int i=0;i<lim;i++)
		for(int j=0;j<lim;j++)
			for(int k=0;k<lim;k++){
				g[i^j^k]=g[i^j^k]+f[0][i]*f[1][j]*f[2][k];
				// if(f[0][i].x&&f[1][j].x&&f[2][k].x){
				// 	printf("%d %d %d : %d\n",i,j,k,f[0][i]*f[1][j]*f[2][k]);
				// }
			}
	// for(int i=0;i<3;i++)fwt(f[i]);
	// for(int i=0;i<3;i++)g[i]=f[0][i]*f[1][i]*f[2][i];
	// fwt(g);
	// z invlim=fpow(lim,mod-2);
	// for(int i=0;i<lim;i++)g[i]=g[i]*invlim;
	// for(int i=0;i<lim;i++){
	// 	printf("%d : %d\n",i,g[i]);
	// }
	printf("%d\n",g[0]);
}

Measured memory_bytes: 15104
#include <iostream>
using namespace std;
 
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d){
    cout << "Left" << endl;
  }
  else if(a + b < c + d){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

template <typename T>
int binary_search(T &arr, int key) {
    int left = 0, right = (int)arr.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (arr[mid] == key) return mid;
        else if (arr[mid] > key) right = mid - 1;
        else if (arr[mid] < key) left = mid + 1;
    }
    return -1;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,q;
    cin>>n;
    vi s(n);
    REP(i,n)cin>>s[i];
    cin>>q;
    vi t(q);
    REP(i,q)cin>>t[i];

    // sort(ALL(s));
    s.erase(unique(ALL(s)), s.end()); //sには重複する値がある
    // sort(ALL(t));
    
    int ans=0;
    
    REP(i,q){
        if(binary_search(s,t[i]) != -1) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  int cnt[N] = {};
  for (int i=0 ; i<N ; i++) {
    int A;
    cin >> A;
    cnt[A]++;
  }

  long long ans = 1;
  if (N%2 == 1) {
    if (cnt[0] != 1) {
      ans = 0;
    } else {
      for (int i=2 ; i<=N-1 ; i += 2) {
        if (cnt[i] != 2) {
          ans = 0;
          break;
        }
        ans = ans * 2 % 1000000007;
      }
    }
  } else if (N%2 == 0) {
    for (int i=1 ; i<=N-1 ; i += 2) {
      if (cnt[i] != 2) {
        ans = 0;
        break;
      }
      ans = ans * 2 % 1000000007;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
fn main(){
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v:Vec<i32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    let mut x = v[0];
    let mut a = v[1];
    let mut b = v[2];

    if (a-x).abs() < (b-x).abs(){
        println!("A");
    }
    else{
        println!("B");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

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

  bool yes = true;
  if (y < 2 * x)
    yes = false;
  y -= 2 * x;
  if (y % 2 == 1)
    yes = false;
  y /= 2;
  if (y > x)
    yes = false;
  if (yes)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3644
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A = 0, B = 0;
	int C = 0;
	scanf("%d %d", &A, &B);
	if(A > B) {

	} else {
		int temp = B;
		B = A;
		A = temp;
	}
	C = (A - B)%2;
	if (C != 0) {
		printf("IMPOSSIBLE\n");
	} else {
		printf("%d\n", ((A - B)/2) + B);
	}
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>
struct edge{
	lli to;
	lli cost;
};
 
#define MAX_V 1000000
 
vector<edge> G[MAX_V];
vector<edge> GG[MAX_V];

lli n;
 
vector<lli> dijkstra1(lli s){
	priority_queue<P,vector<P>,greater<P>> que;
	vector<lli> d(n+2,INF);
	//fill(d,d+n+2,INF);
	d[s]=0;
	que.push(P(0,s));
 
	while(!que.empty())
	{
		P p = que.top();
		que.pop();
		lli v = p.second;
		if(d[v] < p.first)continue;
 
		for(lli i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v]+e.cost){
				d[e.to] = d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	return d;
}

vector<lli> dijkstra2(lli s){
	priority_queue<P,vector<P>,greater<P>> que;
	vector<lli> d(n+2,INF);
	//fill(d,d+n+2,INF);
	d[s]=0;
	que.push(P(0,s));
 
	while(!que.empty())
	{
		P p = que.top();
		que.pop();
		lli v = p.second;
		if(d[v] < p.first)continue;
 
		for(lli i=0;i<GG[v].size();i++){
			edge e = GG[v][i];
			if(d[e.to] > d[v]+e.cost){
				d[e.to] = d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	return d;
}
 
signed main(){

	lli m,s,t;
	cin>>n>>m>>s>>t;
	s--,t--;

	REP(i,0,m){
		lli u,v,a,b;
		cin>>u>>v>>a>>b;
		u--,v--;
		G[u].push_back({v,a});
		G[v].push_back({u,a});
		GG[v].push_back({u,b});
		GG[u].push_back({v,b});
	}

	auto yen = dijkstra1(s);

	auto snk = dijkstra2(t);

	vector<lli> ans;
	ans.push_back(1e15-yen[n-1]-snk[n-1]);

	lli now = 1e15-yen[n-1]-snk[n-1];
	ans.push_back(now);
	for(lli i=n-2;i>=0;i--){
		lli tmp = 1e15-yen[i]-snk[i];
		now = max(now,tmp);
		ans.push_back(now);
	}

	reverse(ans.begin(),ans.end());

	REP(i,0,ans.size()-1){
		cout<<ans[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 62208
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    ll t1, t2, a1, a2, b1, b2;
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(a1*t1+a2*t2==b1*t1+b2*t2){
		cout<<"infinity"<<endl;
		return 0;
	}
	if(a1*t1+a2*t2<b1*t1+b2*t2){
		swap(a1, b1);
		swap(a2, b2);
	}
	ll d=a1*t1+a2*t2-(b1*t1+b2*t2);
	ll e=b1*t1-a1*t1;
	if(e<0){
		cout<<0<<endl;
		return 0;
	}
	if(e%d==0){
		cout<<1+2*(e/d-1)+1<<endl;
	}else{
		cout<<1+2*(e/d)<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
// AOJ 0601
#include<cstdio>
#include<queue>
#include<vector>
#include<limits>
#include<utility>
#define rep(i,a) for(int i=0;i<(a);++i)

typedef long long ll;
typedef std::pair<int, int> P;
typedef std::pair<ll, int> St;

const int MAX_N = 100000;
const ll INF = std::numeric_limits<ll>::max()>>1;

int N, M, X;
int H[MAX_N];
std::vector<P> G[MAX_N];

int main()
{
	scanf( "%d%d%d", &N, &M, &X );
	rep( i, N )
		scanf( "%d", H+i );
	rep( i, M )
	{
		int A, B, T;
		scanf( "%d%d%d", &A, &B, &T );
		--A; --B;
		G[A].push_back( P( B, T ) );
		G[B].push_back( P( A, T ) );
	}

	std::vector<ll> d( N, -INF );
	std::priority_queue<St> pque;
	pque.push( St( X, 0 ) );
	
	while( !pque.empty() )
	{
		St st = pque.top(); pque.pop();
		ll &dist = st.first;
		int &v = st.second;
		
		if( d[v] != -INF )
			continue;

		d[v] = dist;
		rep( i, G[v].size() )
		{
			P &e = G[v][i];

			if( e.second > H[v] )
				continue;

			pque.push( St( std::min( dist-e.second, (ll)H[e.first]), e.first ) );
		}
	}

	if( d[N-1] == -INF )
		puts("-1");
	else
		printf( "%lld\n", X+H[N-1]-d[N-1]*2 );

	return 0;
}

Measured memory_bytes: 28952