akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

void out(int a, int b, int c) {
	cout << "a:" << a << " b:"  << b << " c:" << c << endl;
}

bool check(int a, int b, int c) {
	if(a & 1) return false;
	if(b & 1) return false;
	if(c & 1) return false;
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 100;
	int ans = 0;
	while(cnt--) {
		if(!check(a, b, c)) break;
		ans++;
		int na = (b + c) / 2;
		int nb = (c + a) / 2;
		int nc = (a + b) / 2;
		a = na, b = nb, c = nc;
	}
	cout << (ans > 90 ? - 1 : ans) << endl;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, int>mp;
		map<int, int>revmp;
		int id = 0;
		vector<vector<int>>diss(10, vector<int>(10, 1e8));
		for (int i = 0; i < N; ++i) {
			int a, b, n; cin >> a >> b >> n;
			if (mp.find(a) == mp.end()) {
				mp[a] = id;
				revmp[id] = a;
				id++;
			}
			if (mp.find(b) == mp.end()) {
				mp[b] = id;
				revmp[id] = b;
				id++;
			}
			diss[mp[a]][mp[b]] = min(diss[mp[a]][mp[b]], n);
			diss[mp[b]][mp[a]] = min(diss[mp[b]][mp[a]], n);
		}
		for (int i = 0; i < id; ++i) {
			diss[i][i] = 0;
		}
		for (int k = 0; k < id; ++k) {
			for (int i = 0; i < id; ++i) {
				for (int j = 0; j < id; ++j) {
					diss[i][j] = min(diss[i][k] + diss[k][j], diss[i][j]);
				}
			}
		}
		pair<int, int>amin(1e9, 1e9);
		for (int s = 0; s < id; ++s) {
			int len = 0;
			for (int t = 0; t < id; ++t) {
				len += diss[s][t];
			}
			if (amin > make_pair(len, revmp[s])) {
				amin = make_pair(len, revmp[s]);
			}
		}
		cout << amin.second << " " << amin.first << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll>vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    vector<ll>dp(n);dp[0]=0;dp[1]=abs(vec[1]-vec[0]);
    loop(2,n) {
        dp[i]=min(abs(vec[i]-vec[i-1])+dp[i-1],abs(vec[i]-vec[i-2])+dp[i-2]);
        //cout << dp[i] << endl;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
void fill_array(long long* s, long long* e, bool forwards) {
	long long* ptr;
	*s = max(*s, 0LL);
	while (s != e) {
		if (forwards) ptr = s++;
		else ptr = s--;
		*s = max(*s, *ptr + 1);
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str;
	cin >> str;
	long long minv[str.length() + 1], ans = 0;
	fill_n(minv, str.length() + 1, 0);
	int fid = 0;
	for (int i = 1; i < str.length(); ++i) {
		if (str[i] != str[i - 1]) {
			if (str[i - 1] == '<') fill_array(&minv[fid], &minv[i], true);
			else fill_array(&minv[i], &minv[fid], false);
			fid = i;
		}
	}
	if (str.back() == '<') fill_array(&minv[fid], &minv[str.length()], true);
	else fill_array(&minv[str.length()], &minv[fid], false);
	for (long long i: minv) ans += i;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4764
#include <stdio.h>
#include<stdlib.h>

int partition(int * ,int ,int );

int main(){
  int i,n,q;
  int *a;

  scanf("%d",&n);

  a = (int*)malloc(n*sizeof(int));

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

  q = partition( a , 0 , n-1 );

  for( i=0 ; i<n ; i++ ){
    if( i == q ){
      printf("[");
      printf("%d",a[i]);
      printf("]");
    }
    else  printf("%d",a[i]);
    if( i != n-1 ) printf(" ");
  }

  printf("\n");

  return 0;
}


int partition(int *a ,int p,int r){
  int x,i,tmp,j;

  x = a[r];
  i = p-1;
  for( j=0 ; j<r ; j++ ){
    if( a[j] <= x ){
      i++;
      tmp = a[j];
      a[j] = a[i];
      a[i] = tmp;
    }
  }
  tmp = a[r];
  a[r] = a[i+1];
  a[i+1] = tmp;

  return i+1;
}

Measured memory_bytes: 996
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		
		int n=scan.nextInt();
		if(n==0)break;
		int s[]=new int[7];
		for(int i=0;i<n;i++)
		    {
			
			int old=scan.nextInt();
			if(old>=70)old=60;
			
			s[old/10]++;
		    }
		for(int i=0;i<7;i++)
		    {
			System.out.println(s[i]);
		    }
	    }
    }
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


            var cin = GetIntArray().Select(s => s == 1 ? 14 : s).ToArray();
            var ans = cin[0] > cin[1] ? "Alice" : cin[0] == cin[1] ? "Draw" : "Bob";

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

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

int main() {
  int N, tmp, count = 0;

  cin >> N;
  vector<int> cards(N);
  
  for(int i = 0; i < N; i++){
    cin >> cards.at(i);
  }
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(cards.at(i) < cards.at(j)){
        tmp = cards.at(i);
        cards.at(i) = cards.at(j);
        cards.at(j) = tmp;
      }
    }
  }
  
  tmp = 0;
  for(int i = 0; i < N; i++){
    if (tmp == cards.at(i)){
      tmp = cards.at(i);
      continue;
    }
    tmp = cards.at(i);
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A[100000], S;
vector<int>p, m;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A, A + N);
	if (A[N - 1] < 0) {
		p.push_back(A[N - 1]);
		S += A[N - 1];
		for (int i = 0; i < N - 1; ++i) {
			S -= A[i];
			m.push_back(A[i]);
		}
	}
	else if (A[0] >= 0) {
		m.push_back(A[0]);
		S -= A[0];
		for (int i = 1; i < N; ++i) {
			S += A[i];
			p.push_back(A[i]);
		}
	}
	else {
		for (int i = 0; i < N; ++i) {
			if (A[i] < 0) {
				S -= A[i];
				m.push_back(A[i]);
			}
			else {
				S += A[i];
				p.push_back(A[i]);
			}
		}
	}
	cout << S << endl;
	for (int i = 1; i < N; ++i) {
		if (m.size() >= p.size()) {
			cout << p.back() << sp << m.back() << endl;
			int t = p.back() - m.back();
			m.pop_back();
			p.pop_back();
			p.push_back(t);
		}
		else {
			cout << m.back() << sp << p.back() << endl;
			int t = m.back() - p.back();
			m.pop_back();
			p.pop_back();
			m.push_back(t);
		}
	}
}

Measured memory_bytes: 2808
#include<bits/stdc++.h>
using namespace std;
double ff(int m)
{
    double x=(double)1/((double)4*m);
    return x;
}
int main()
{
int i,j,n,m;
cin>>n>>m;
int v[n],total=0;
for(i=0;i<n;i++)
{
    cin>>v[i];
    total+=v[i];
}
double temp=ff(m)*(double)total,g;
int co=n;
for(i=0;i<n;i++)
{
    if((double)v[i]<temp) co--;
}
if(co>=m) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int A,B,X;
	cin >> A >> B >> X;
	cout << ((B >= X - A && X - A >= 0) ? "YES" : "NO") << endl;
	
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N, M, K = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(M)]
    CD = [tuple(map(int, input().split())) for _ in range(K)]

    uf = UnionFindTree(N)
    friend_or_block = [set() for _ in range(N)]
    for a, b in AB:
        a, b = a-1, b-1
        uf.union(a, b)
        friend_or_block[a].add(b)
        friend_or_block[b].add(a)
    for c, d in CD:
        c, d = c-1, d-1
        if uf.same(c, d):
            friend_or_block[c].add(d)
            friend_or_block[d].add(c)
    
    print(*[uf.size(i) - len(friend_or_block[i]) - 1 for i in range(N)])

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)]

if __name__ == '__main__':
    main()

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

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
struct e{int a,b;};
int ans=1e9,n,a[20],b[20],now,p,q;
e v[20];
stack<int> sta;
#define rep(i,n) for(int i=0;i<(n);i++)

signed main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,1<<n){
    now=0;
    rep(j,n)v[j]={(i>>j)&1?b[j]:a[j],j};
    rep(j,n){
      int k=j;
      while(k&&v[k].a<v[k-1].a)swap(v[k],v[k-1]),now++,k--;
    }
    rep(j,n)if(((i>>v[j].b)+v[j].b-j)&1)sta.push(v[j].a*1000+j);
    if(sta.size()&1)now=1000,sta.pop();
    while(sta.size()){
      p=sta.top();sta.pop();q=sta.top();sta.pop();
      now+=((p-q)&1?p-q:1000);
    }
    chmin(ans,now);
  }
  cout<<(ans<1000?ans:-1)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long m, n, k;

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

    if(2*m<n)
        k = (2*m+n)/4;
    else if(2*m==n)
        k = m;
    else
        k = n/2;

    printf("%lld\n", k);

    return 0;
}


Measured memory_bytes: 128
W,H,N=map(int,input().split())
x=[]
y=[]
a=[]
for i in range(N):
  s=input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  a.append(int(s[2]))
w=[0,W,0,H]
for i in range(N):
  if a[i]==1:
    w[0]=max(w[0],x[i])
  elif a[i]==2:
    w[1]=min(w[1],x[i])
  elif a[i]==3:
    w[2]=max(w[2],y[i])
  else:
    w[3]=min(w[3],y[i])
if w[1]-w[0]<=0 or w[3]-w[2]<=0:
  S=0
else:
  S=(w[1]-w[0])*(w[3]-w[2])
print(S)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, M, cnt = 0, SM; cin >> N >> M;
  vecll AS(N);
  REP(i, N) cin >> AS[i];
  SM = accumulate(AS.begin(), AS.end(), 0);
  for (auto a : AS) if (4*M*a >= SM) cnt++;
  cout << (cnt >= M ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n,m; ;cin >> n >> m;
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    double div = (double)sum / (4*m);
    for(int i = 0; i < n; i++){
        if(a[i] >= div) cnt++;
    }
    if(cnt >= m)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

struct card;
int paritition(card a[], int left, int right);

struct card
{
    char surt;
    int value;
};

void printcard(int n, card a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i].surt << " " << a[i].value << endl;
    }
    
}

int paritition(card a[], int left, int right)
{
    int x = a[right].value;

    int i = left - 1;
    for (int j = left; j < right; j++)
    {
        if (a[j].value <= x)
        {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i + 1], a[right]);
    return i + 1;
}

void quicksort(card a[], int left, int right)
{
    if (left < right)
    {
        int q = paritition(a, left, right);
        quicksort(a, left, q - 1);
        quicksort(a, q + 1, right);
    }
}

void merge(card a[], int left, int right, int middle)
{
    int const inf = 1e9 + 7;
    int n1 = middle - left;
    int n2 = right - middle;

    card leftarray[n1 + 1], rightarray[n2 + 1];
    for (int i = 0; i < n1; i++)
    {
        leftarray[i] = a[left + i];
    }
    leftarray[n1].surt = 'A';
    leftarray[n1].value = inf;

    for (int i = 0; i < n2; i++)
    {
        rightarray[i] = a[middle + i];
    }
    rightarray[n2].surt = 'A';
    rightarray[n2].value = inf;

    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        if (leftarray[i].value <= rightarray[j].value)
        {
            a[k] = leftarray[i];
            i++;
        }
        else
        {
            a[k] = rightarray[j];
            j++;
        }
    }
}

void my_margesort(card a[], int left, int right)
{
    int middle;
    if (left + 1 < right)
    {
        middle = (left + right) / 2;
        my_margesort(a, left, middle);
        my_margesort(a, middle, right);
        merge(a, left, right, middle);
    }
}

bool equal_check(card a[], card b[], int n){
    bool ret = false;
    int checksum = 0;
    for (int i = 0; i < n; i++){
        if (a[i].surt == b[i].surt && a[i].value == b[i].value)
            checksum++;    
    }
    if (checksum == n) ret = true;
    return ret;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n;
    cin >> n;
    card a[n], b[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].surt >> a[i].value;
        b[i] = a[i];
    }
    quicksort(a, 0, n - 1);
    my_margesort(b, 0, n);
    cout << (equal_check(a,b,n) ? "Stable" : "Not stable") << endl;
    printcard(n, a);
    
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

struct UnionFind{
	vector<int> par;
	UnionFind(int n){
		FOR(i,0,n)par.pb(i);
	}
	int root(int x){
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y)return;
		par[x] = y;
	}
	bool same(int x, int y){
		return root(x) == root(y);
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m;
    cin >> n >> m;
    UnionFind uf = UnionFind(n+m);
    REP(i,n){
        int32 k;
        cin >> k;
        REP(j,k){
            int32 l;
            cin >> l;
            l--;
            uf.unite(i, n + l);
        }
    }
    bool ans = true;
    FOR(i,1,n)if(!uf.same(0,i))ans = false;
    YES(ans);
    return 0;
}

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

int main(){
    int cnt=1;
    long x,y, tmp;
    cin >> x >> y;
    
    while(y - x >= 0){
        x *=2;
        cnt++;
    }
    cout << (cnt -1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(n):
    ans += b[i]

pre = -1
for i in range(n):
    if a[i] == pre+1:
        ans += c[pre-1]
    pre = a[i]

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  string s; cin >> s;
  V<> a(n);
  for (int i = 0; i < n; i++) a[i] = i + 1;
  for (int i = 0; i < m; i++) {
    int l, r; cin >> l >> r, l--;
    for (int j = l; j < r; j++) a[j] = max(a[j], r);
  }
  V<> c(n + 1);
  for (int i = 0; i < n; i++) c[i + 1] = c[i] + (s[i] == '1');
  VV<lint> dp; assign(dp, n + 1, n + 1);
  dp[1][0] = a[0] - c[a[0]] > 0;
  dp[1][1] = c[a[0]] > 0;
  for (int i = 1; i < n; i++) for (int j = 0; j < n + 1; j++) {
    if ((a[i] - i) - (c[a[i]] - j) > 0) (dp[i + 1][j] += dp[i][j]) %= mod;
    if (c[a[i]] - j > 0) (dp[i + 1][j + 1] += dp[i][j]) %= mod;
  }
  lint res = 0;
  for (int j = 0; j < n + 1; j++) (res += dp[n][j]) %= mod;
  cout << emod(res) << '\n';
}

Measured memory_bytes: 70784
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

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


def main():
    n = int(input())
    p = [int(pi) for pi in input().split()]

    c = 0
    for i in range(1, n - 1):
        c += (p[i - 1] < p[i] < p[i + 1]) | (p[i + 1] < p[i] < p[i - 1])

    print(c)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 28908
#include<stdio.h>
int main (void)
{
    int H,W,i,j;
    while(1)
    {
        scanf("%d %d",&H,&W);
        if (H==0 && W==0) break;

        for(i=0;i<H;i++)
        {
            for(j=0;j<W;j++)
            {
                if(i==0||i==H-1||j==0||j==W-1)
                printf("#");
                else
                printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
  string s;
  cin >> s;

  bool flg = true;
  string t = s;
  reverse(all(t));

  if(s != t) flg = false;
  int n = s.size();
  for(int i=0; i<(n-1)/2; i++){
    if(s[i] != s[(n-1)/2 - i - 1]) flg = false;
  }
  //cout << flg << endl;
  for(int i=(n+3)/2; i<n; i++){
    if(s[i-1] != s[n - i]) flg = false;
  }

  if(flg) printf("Yes");
  else printf("No");
}

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

int main(){
    int n, i, j, c, minj, tmp;
    int list[100] = {};
    c = 0;
    
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> list[i];
    }
    
    for(i = 0; i < n; i++){
        minj = i;
        for(j = i; j < n; j++){
            if(list[j] < list[minj]){
                minj = j;
            }
        }
        if(i != minj){
            swap(list[i], list[minj]);
            c++;
        }
    }
    
    for(i = 0; i < n; i++){
        cout << list[i];
        if(i == n-1) cout << endl;
        else cout << " ";
    }
    
    cout << c << endl;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin >> n;
    cout << 3*n*n << endl;
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;
int main()
{
	int N, K;
	string s;	
	cin >> N >> K;
	cin >> s;
	int ans = 1;
	int cnt = (s[0] == '0') ? 1 : 0;
	queue<int> q({0}); //store start inx of '1' in queue
	int inx = 1;
	while(inx < N)
	{
		while(inx < N)
		{
			if(s[inx] == '0' && s[inx-1] == '1')
			{
				cnt++;
				if(cnt > K)
				{
					cnt--;
					break;
				}
			}
			else if(s[inx] == '1' && s[inx-1] == '0')
			{
				q.emplace(inx);
			}
			inx++;
		}
		ans = max(ans, inx - q.front());
		q.pop();
		inx++;
	}

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


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AtCoder solver = new AtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            String op = in.next();
            int b = in.nextInt();

            if (op.equals("+")) {
                out.println(a + b);
            } else {
                out.println(a - b);
            }
        }

    }
}



Measured memory_bytes: 20948
#include<stdio.h>
int gcd(int a,int b){
    if(a<b){
        int t=b;
        b=a;
        a=t;
    }
    int c=1;
    while(c!=0){
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int main(void){
    int w,h,c,g;
    scanf("%d %d %d",&w,&h,&c);
    g=gcd(w,h);
    printf("%d\n",(w/g)*(h/g)*c);
	return 0;		
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,memo=0,sum=0;
  cin >>n;
  for(int i=0;i<n-1;i++){
    int b;  
    cin >>b;
      if(i==n-2){sum+=b;}
    if(i==0){sum+=b;}
    else if(b<=memo){sum+=b;}
      else if(b>memo){sum+=memo;}
      memo=b;
  }

  cout <<sum<<endl;
}

Measured memory_bytes: 256
import java.util.* ;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(c >= a && c <= b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 20948
n, m, l = map(int, input().split())

mathlist1 = [list(map(int, input().split())) for x in range(n)]
mathlist2 = [list(map(int, input().split())) for y in range(m)]
mathlist3 = list(map(list, zip(*mathlist2)))
mathlist4 = []

for d in mathlist1:
    interim = []
    for e in mathlist3:
        result = 0
        for f, g in zip(d, e):
            result += f * g
        interim.append(result)
    mathlist4.append(interim)

for h in mathlist4:
    print(*h, sep=' ')



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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    long long ans = 0;
    for (int i=0; i<(1<<(n-1)); i++) {
        long long sum = 0;
        for (int j=0; j<n; j++) {
            sum *= 10;
            sum += s[j] - '0';
            if (i>>j & 1) {
                ans += sum;
                sum = 0;
            }
        }
        ans += sum;
    }
    cout << ans << endl;
}


/*
"125" : string
1 | 2 | 5
n-1 bit の bitを用いた全探索を行えば良い。
iビット目が 0 ならば、 足し算記号なし
iビット目が 1 ならば、 足し算記号あり
00 → 125
01 → 12 + 5 
10 → 1 + 25
11 → 1 + 2 + 5
*/

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt();
		int k=sc.nextInt();
		char[]in=sc.nextLine().toCharArray();
		int[]count=new int[n];int[] cha=new int[n];
		int i=0;int c=0;
		while(i<n) {
			if(in[i]=='0') {
				cha[c]=0;int z=0;
				while(i<n && in[i]=='0') {
					z++;i++;
				}
				count[c++]=z;
			}
			else {
				cha[c]=1;int o=0;
				while(i<n && in[i]=='1') {
					o++;i++;
				}
				count[c++]=o;
			}
		}
		int[]pref=new int[c];pref[0]=count[0];
		for(int j=1;j<c;j++) {
			pref[j]=pref[j-1]+count[j];
		}
		int ans=0;
		for(int j=0;j<c;j++) {
			int prev=j-2*k+1;
			if(prev<=0) {
				ans=Math.max(ans,pref[j]);
			}
			else {
				if(cha[prev]==0)prev--;
				if(prev<=0) {
					ans=Math.max(ans,pref[j]);
				}
				else
					ans=Math.max(ans,pref[j]-pref[prev-1]);
			}
		}
		pw.println(ans);
		pw.close();
		pw.flush();
 
	}
	static int gcd(int a, int b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
int L,H;
vector<int> A;
string S,T;
//=============================
void input()
{
    cin>>N;
    A.resize(N);
    rep(i,N){
        cin>>A[i];
    }
}
//=============================
void func(){}
//=============================
void solve()
{
    map<int,int> mm;
    int ov = 0;
    rep(i,N){
        if (A[i]<3200){
            mm[A[i]/400]++;
        }
        else ov++;
    }


    int val = mm.size();

    printf("%lld %lld\n", (max(1LL,val)),  val+ov);



}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int cwa = b / c - (a - 1) / c;
	int dwa = b / d - (a - 1) / d;
	int ryo = b / lcm(c, d) - (a - 1) / lcm(c, d);
	cout << (b - a + 1) - (cwa + dwa - ryo) << endl;
}

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

namespace cShaprTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().ToArray()[0];

            if (input == "A")
            {
                Console.WriteLine("T");
            }
            else if (input == "C")
            {
                Console.WriteLine("G");
            }
            else if (input == "G")
            {
                Console.WriteLine("C");
            }
            else if (input == "T")
            {
                Console.WriteLine("A");
            }
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string abc = "ABC";

void solve() {
	cin >> N;
	string S; cin >> S;
	int res = 0;
	rep(i, 0, N - 2) {
		bool ok = true;
		rep(j, 0, 3) {
			if(abc[j] != S[i + j]) {
				ok = false; break;
			}
		}
		res += ok;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=400005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int p[max_n];
int n,a[max_n],b[max_n];
int nex[max_n];
void get_next(int *s,int len)
{
    int i=0,j;
    nex[0]=j=-1;
    while(i<len)
    {
        if(j==-1||s[i]==s[j])nex[++i]=++j;
        else j=nex[j];
    }
}
int ans=0;
void kmp(int *s1,int len1,int *s2,int len2)
{
    int i=0,j=0;
    while(i<len1)
    {
        if(j==-1||s1[i]==s2[j])++i,++j;
        else j=nex[j];
        if(j==len2)
        {
            //printf("%d\n",i-(len2-1));
            if(i-len2<n){
                printf("%d %d\n",i-len2,p[i-len2]);
            }
            j=nex[j];
        }
    }
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",a+i);
    for(int i=0;i<n;i++)scanf("%d",b+i);
    for(int i=0;i<n;i++)p[i]=a[i]^b[0];
    if(n==1){
        printf("0 %d\n",a[0]^b[0]);
        return 0;
    }
    for(int i=0;i<n-1;i++)b[i]=b[i]^b[i+1];
    for(int i=0;i<n;i++)a[n+i]=a[i];
    for(int i=0;i<n*2-1;i++)a[i]=a[i]^a[i+1];
    get_next(b,n-1);
    kmp(a,2*n-1,b,n-1);
    return 0;
}

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

class Main {
    public static void main(String[] Args) {

        Scanner sc = new Scanner(System.in);

        String x = sc.next();
        String y = sc.next();

        if (x.matches("1|3|5|7|8|10|12") && y.matches("1|3|5|7|8|10|12")) {
            System.out.println("Yes");
        } else if (x.matches("4|6|9|11") && y.matches("4|6|9|11")) {
            System.out.println("Yes");
        } else if (x.matches("2") && y.matches("2")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
#define ll long long
#define ld long double
ll a[100007], b[100007];
int main()
{
	int n; cin >> n;
	for (int i = 0; i <= n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i])
		{
		if (a[i] > b[i])
		{
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		else
		{
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
		}

		if (i+1<=n && b[i])
		{
			if (a[i + 1] > b[i])
			{
				ans += b[i];
				a[i + 1] -= b[i];
				b[i] = 0;
			}
			else
			{
				ans += a[i + 1];
				a[i + 1] = 0;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
<?php

$N = trim(fgets(STDIN));
$D = trim(fgets(STDIN));
$D = explode(' ', $D);

$ans = 0;
for ($i=0; $i < count($D); $i++) { 
    for ($j=$i + 1; $j < count($D); $j++) { 
        $ans += $D[$i] * $D[$j];
    }
}

echo $ans;

Measured memory_bytes: 3828
using System;

public class ABC0125_A1 {
    private static void Main(string[] args) {
        string input = Console.ReadLine().Trim();

        Prepare(input);
    }

    private static void Prepare(string input) {
        var numbers = input.Split(' ');
        var interval = int.Parse(numbers[0]);
        var efficiency = int.Parse(numbers[1]);
        var duration = float.Parse(numbers[2]) + 0.5f;

        Compute(interval, efficiency, duration);
    }

    private static void Compute(int interval, int efficiency, float duration) {
        var numOfTimes = Math.Floor(duration / interval);
        var numOfBiscuits = efficiency * numOfTimes;

        OutputAnswer(numOfBiscuits.ToString());
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);
}

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

int main(){
    long A, B, K;
    cin >> A >> B >> K;
    
    if((A-K) >= 0) cout << (A-K) << " " << B << endl;
    else if((B-(K-A) >= 0)) cout << 0 << " " << (B-(K-A)) << endl;
    else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdint>

using namespace std;

template <class T, class Updater, class Aggregator>
class LazySegmentTree {
    size_t n, m;
    vector<T> tree, buf;
    vector<bool> buffering;
    Updater update;
    Aggregator aggregate;
    const T e;
    void buffer(size_t i, T x) {
        buffering[i] = true;
        buf[i] = update(buf[i], x);
        tree[i] = update(buf[i], x);
    }
    inline void propagate(size_t i) {
        if (!buffering[i]) return;

        buffer(i<<1|0, buf[i]);
        buffer(i<<1|1, buf[i]);
        buf[i] = e;
        buffering[i] = false;
    }
    inline void modify(size_t l, size_t r, const T &x, size_t i, size_t a, size_t b) {
        if (r <= a || b <= l) return;
        if (l <= a && b <= r) {
            buffer(i, x);
            return;
        }
        propagate(i);

        size_t c=(a+b)>>1;
        modify(l, r, x, i<<1|0, a, c);
        modify(l, r, x, i<<1|1, c, b);
        tree[i] = aggregate(tree[i<<1|0], tree[i<<1|1]);
    }
    T query(size_t l, size_t r, size_t i, size_t a, size_t b) {
        if (r <= a || b <= l) return e;
        if (l <= a && b <= r) return tree[i];

        propagate(i);
        size_t c=(a+b)>>1;
        T vl=query(l, r, i<<1|0, a, c);
        T vr=query(l, r, i<<1|1, c, b);

        return aggregate(vl, vr);
    }
public:
    LazySegmentTree(size_t m, T e=T()): n(1), m(m), e(e) {
        while (n < m) n <<= 1;

        tree.assign(n<<1, e);
        buf.assign(n<<1, e);
        buffering.assign(n<<1, false);
    }
    void modify(size_t l, size_t r, const T &x) {
        modify(l, r, x, 1, 0, n);
    }
    T query(size_t l, size_t r) {
        return query(l, r, 1, 0, n);
    }
};

template <class T>
struct Updater {
    T operator ()(const T &lhs, const T &rhs) {
        return rhs;
    }
};

template <class T>
struct Min {
    T operator ()(const T &lhs, const T &rhs) {
        return min(lhs, rhs);
    }
};

int main() {
    size_t n;
    int q;
    scanf("%zu %d\n", &n, &q);

    int64_t e=(1LL<<31)-1;
    LazySegmentTree<int64_t, Updater<int64_t>, Min<int64_t>> tree(n, e);
    for (int i=0; i<q; ++i) {
        int query;
        scanf("%d", &query);

        if (query == 0) {
                size_t s, t;
                int64_t x;
                scanf("%zu %zu %lld", &s, &t, &x);
                tree.modify(s, t+1, x);
        } else if (query == 1) {
                size_t s, t;
                scanf("%zu %zu", &s, &t);
                printf("%lld\n", tree.query(s, t+1));
        } else {
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 6704