akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a = cin.Int();
			int b = cin.Int();
			int c = cin.Int();
			int d = cin.Int();
			int e = cin.Int();
			int f = cin.Int();

			int max = 30;
			var can = new bool[max + 1];
			can[0] = true;
			for (int i = 0; i <= max; i++) {
				if (can[i] == false) {
					continue;
				}

				if (i + a <= max) {
					can[i + a] = true;
				}

				if (i + b <= max) {
					can[i + b] = true;
				}
			}

			int water = 100 * a;
			int suger = 0;
			double dence = (double)suger / (water + suger);
			for (int i = 1; i < max; i++) {
				if (can[i] == false) {
					continue;
				}

				int s = Math.Max(0, Math.Min(i * e, f - (i * 100)));
				var scan = new bool[s + 1];
				scan[0] = true;
				for (int j = 0; j <= s; j++) {
					if (scan[j] == false) {
						continue;
					}

					if (j + c <= s) {
						scan[j + c] = true;
					}

					if (j + d <= s) {
						scan[j + d] = true;
					}
				}

				int tempS = 0;
				for (int j = s; j >= 0; --j) {
					if (scan[j]) {
						tempS = j;
						break;
					}
				}

				double tempD = (double)tempS / (i * 100 + tempS);
				if (tempD > dence) {
					dence = tempD;
					water = i * 100;
					suger = tempS;
				}
			}

			Console.WriteLine($"{water + suger} {suger}");
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>

const int MOD = 100000007;
const int maxn = 2e5 + 10;
const int maxm = 3e5 + 10;
const double PI = acos(-1.0);



int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string s;
    cin >> s;
    int cnt = 0 ;
    for(int i = 0 ; i < s.size(); i++)
        if(s[i] == 'o') cnt++;
    cnt += 15 - s.size();
    if(cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
 }



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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'A'){
            if(i + 1 <n && i + 2 < n && s[i + 1] == 'B' && s[i + 2] == 'C') 
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    for (auto &e : a) cin >> e[0] >> e[1] >> e[2];

    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i - 1][j]);
                }
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}


Measured memory_bytes: 13184
#include<iostream>
using namespace std;
int main(){
	long int a,ae,b,be,w;
	cin>>w>>a>>b;
if(a>=1 && a<=10^5 && b>=1 && b<=10^5 && w>=1 && w<= 10^5)	{

	ae=a+w;
	be=b+w;
	if((b>=a && b<=ae)||(be>=a && be<=ae))
	cout<<0;
	else
	if(b>ae)
	cout<<b-ae;
	else
	cout<<a-be;
}
}
	

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

using namespace std;

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

    if(x == W/2 && y == H/2){
        cout << W*H/2 << " " << 1;
    }else{
        
        cout << W*H/2 << " " << 0;
    }
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

bool solve(int n) {
    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
            if (i * j == n)
                return true;
    return false;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    auto ans=  solve(a);
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from math import sqrt
X=int(input())

def checkprime(x):
  for i in range(1,int(sqrt(x))+1,2):
    #print(i)
    if i == 1:
      continue
    if X%i==0:
      return False
  return True

if X<=2:
  print(X)
  exit()

if X%2==0:
  X+=1
while(1):
  if checkprime(X):
    print(X)
    break
  else:
    X+=2

Measured memory_bytes: 3060
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val aa = listOfInt().sortedDescending()

    var alice = 0
    var bob = 0

    for (i in aa.indices) {
        if (i % 2 == 0) {
            alice += aa[i]
        } else {
            bob += aa[i]
        }
    }

    println(alice-bob)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37936
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val L = readLine().split(" ").map(_.toInt)

  def solve() = {
    var ans = 0
    for {
      i <- 0 until n
      j <- i until n
      k <- j until n
    } {
      val max = Math.max(Math.max(L(i), L(j)), L(k))
      val isTriangle = max < (L(i)+L(j)+L(k)) - max
      val isUnique = L(i) != L(j) && L(i) != L(k) && L(j) != L(k) 
      if(isTriangle && isUnique) ans += 1
    }
    ans
  }

  println(solve())

}



Measured memory_bytes: 54824
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int count(vector<long long> &v){
    int cnt = 0;
    int N = v.size();
    while(true){
        long long mx = -1;
        for(int i=0; i<N; i++)
            mx = max(mx, v[i]);
        if(mx <= N-1) break;

        mx = -1;
        int j;
        for(int i=0; i<N; i++){
            if(v[i] > mx){
                mx = v[i];
                j = i;
            }
        }
        v[j] -= N+1;
        for(int i=0; i<N; i++) v[i]++;

        cnt++;
    }
    return cnt;
}

vector<long long> solve(int N, long long K){
    vector<long long> v(N);
    for(int i=0; i<N; i++) v[i] = i;
    long long M = K / N;
    for(int i=0; i<N; i++) v[i] += M;

    int R = K % N;
    for(int i=0; i<R; i++){
        bool flag = false;
        sort(v.begin(), v.end());

        for(int j=0; j<N; j++){
            vector<long long> tmp = v;
            tmp[j] += N+1;
            for(int k=0; k<N; k++) tmp[k]--;

            long long mx = 0;
            long long mn = 0;
            for(int k=0; k<N; k++){
                mx = max(mx, tmp[k]);
                mn = min(mn, tmp[k]);
            }
            if(mx == tmp[j] && mn >= 0){
                v = tmp;
                flag = true;
                break;
            }
        }
        if(!flag) return vector<long long>();
    }
    for(int i=0; i<N; i++)
        if(v[i] > 10000000000000000 + 1000) return vector<long long>();
    return v;
}

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

    vector<long long> ans;
    for(int N=2; N<=50; N++){
        ans = solve(N, K);
        if(!ans.empty()) break;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define MOD 1000000007
#define pp pop_back
#define MAXN   100001
#define mp make_pair
#define endl '\n'
int main()
{
	string s;
	cin>>s;
	ll i;
	map<char,ll> m;
	for(i=0;i<(ll)s.size();i++)
	{
		m[s[i]]++;
	}
	ll x=s.size();
	ll ans=(x*(x-1))/2;
	char y='a';
	for(i=0;i<26;i++)
	{
		ll tem=m[y];
		ans-=(tem*(tem-1))/2;
		y++;
	}
	cout<<ans+1<<endl;
}


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

int main() {
long long h,w;
cin >> h >> w;
int64_t ans=0;
long long odd_one=(h+1)/2;
long long even_one=h-odd_one;
long long odd_two=(w+1)/2;
long long even_two=w-odd_two;
ans = (odd_one*odd_two+even_one*even_two);
if(h==1||w==1){cout <<"1";
return 0;}
cout << ans;
}


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

int main(void)
{
    int j, o, i;
    char c, now;
    int ans;
    
    c = now = 'K';
    j = o = i = 0;
    ans = 0;
    
    while (1){
        scanf("%c", &c);
        if (now == 'I' && c != 'I'){
            if (j >= o && o <= i){
                ans = ans > o ? ans : o;
            }
            j = o = i = 0;
        }
        
        if (c == '\n'){
            break;
        }
        
        if ((j == 0 || now == 'J') && c == 'J'){
            j++;
            now = 'J';
        }
        else if (now == 'J' && c == 'I'){
            j = o = i = 0;
            now = 'I';
        }
        
        if ((j != 0 || now == 'O') && c == 'O'){
            o++;
            now = 'O';
        }
        else if (now == 'O' && c == 'J'){
            o = i = 0;
            j = 1;
            now = 'J';
        }
        
        if ((o != 0 || now == 'I') && c == 'I'){
            i++;
            now = 'I';
        }
    }
    printf("%d\n", ans);
    
    return (0);
}

Measured memory_bytes: 360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int cnt=0;
  map<char, int> mp;
  for(int i=0;i<4;i++){
    mp[s[i]]++;
    if(mp[s[i]]==1) cnt++;
    if(mp[s[i]]==3){
      cout << "No\n";
      return 0;
    }
  }
  if(cnt>2){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
  return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  int ju=max(A,max(B,C));
  int nao=min(A,min(B,C));
  int yas=(A+B+C)-ju-nao;
  
  int a=ju-yas;
  
  nao=nao+a;
  
  int b=(ju-nao)/2;
  
  if((nao+2*b)==ju){
    cout << a+b << endl;
  }
  else{
    cout << a+b+2 << endl;
  }
}

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

int main(){
  while(1){
    long int a,b,dab,count=0;
    cin >> a >> b;
    if(a==0 && b == 0) break;
    if(a<b) swap(a,b);
    while(1){
      dab=a%b;
      a=b;
      b=dab;
      count++;
      if(dab==0) break;
    }
    cout << a << " " << count << endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

bool isupperCase(char c){
    return (c>=65 && c<=90);
}

ll x;

ll get_ans(ll n){
    return n/x+1;
}

int main() {

    IO; 

    ll n,x;
    cin>>n>>x;
    v(ll) a(n+1,0);
    ll s=0;
    loop(i,0,n){
        cin>>a[i+1];
        s+=a[i+1];
    }
    if(x==0){
        cout<<s<<endl;
        return 0;
    }
    ll ans=0;
    ll dp[n+1]{0};
    dp[0]=0;
    dp[1]=0;
    for(ll i=2;i<=n;i++){
        if(a[i]+a[i-1]<=x){
            continue;
        }
        else{
            ll k=a[i]+a[i-1]-x;
            ans+=k;
            // cout<<i<<" "<<ans<<" ";
            // cout<<endl;
            ll y=a[i-1]+a[i-2];
            if(a[i]-k>=0){
                a[i]-=k;
            }
            else{
                y=a[i];
                a[i]=0;
                a[i-1]-=(k-y);
            }
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int N;
    int A[200000];
    cin>>N;
    multiset<int> s;
    for(int i=0;i<N;i++){
        cin>>A[i];
        s.insert(A[i]);
    }
    //sort(A,A+N);
    int pow2[31];pow2[0]=1;
    for(int i=1;i<31;i++){
        pow2[i]=pow2[i-1]*2;
    }
    //bool IsUsed[200000]={};
    int ans=0;
    while(!s.empty()){
        multiset<int>::iterator it=s.end(); it--;
        int X=*it;
        s.erase(it);//自分は削除
        //cout<<X<<endl;
        int keta,tmp;
        for(int j=0;j<31;j++){
            if(X<pow2[j]){
                keta=j;
                tmp=pow2[j]-X;
                break;
            }
        }
        multiset<int>::iterator it2=s.find(tmp);
        if(it2 != s.end()){//見つかった
            ans++;
            s.erase(it2);
        }
        
        /*
        //A[i]の位置を知る．
        if(!IsUsed[i]){
            IsUsed[i]=true;
            int keta;
            for(int j=0;j<31;j++){
                if(A[i]<pow2[j]){
                    keta=j;
                    break;
                }
            }
            //2^jを作れるか試す．
            int tmp=pow2[keta]-A[i];
            int* p=upper_bound(A,A+N,tmp);
            int X=(int)(p-A);
            X--;
            if(X>=0 && A[X]==tmp){
                if(X!=i){
                    IsUsed[X]=true;
                    ans++;
                }else if(X-1>=0 && A[X-1]==tmp){
                    IsUsed[X-1]=true;
                    ans++;
                }
            }
        }*/
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10496
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//(*'ω'*)ACほちぃ...
int main(){
    string s;cin>>s;
    lint k,ans=0;cin>>k;
    int sz=s.size();
    vector<int> vec(0);
    char rem=s[0];int tmp=1;
    for(int i=1;i<sz;i++){
        if(s[i]!=rem){
            vec.pb(tmp);
            rem=s[i];tmp=1;
        }
        else tmp++;
    }
    vec.pb(tmp);
    if(tmp==sz)ans=(sz*k)/2;
    else{
        if(s[0]!=s[sz-1]){
            for(int x:vec){
                ans+=x/2;
            }
            ans*=k;
        }
        else{
            int front=vec[0];
            int v=vec.size();
            int back=vec[v-1];
            ans+=(front/2)+(back/2);
            ans+=(front+back)/2*(k-1);
            lint tmp2=0;
            for(int i=1;i<v-1;i++){
                tmp2+=vec[i]/2;
            }
            ans+=tmp2*k;
        }
    }
    cout<<ans<<endl;
}

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

void main_()
{
    int X;
    cin >> X;
    vector<pair<int, int>> available_ranges;

    for (int i = 0;; ++i) {
        int from = (i + 1) * 100;
        int to = (i + 1) * 105;
        available_ranges.emplace_back(from, to);
        if (to - from >= 100) {
            available_ranges.emplace_back(to, 100000);
            break;
        }
    }

    auto ans = any_of(
        begin(available_ranges), end(available_ranges),
        [X](auto&& ar) {
            return ar.first <= X && X <= ar.second;
        });

    cout << (ans ? '1' : '0') << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args){

        Scanner s = null;
        String message = "";

        try {
            s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

            while (s.hasNext()) {
                message += s.next();
            }
        } finally {
            if (s != null) {
                s.close();
            }
        }
		char[] chars = message.toCharArray();
		Arrays.sort(chars);
		ArrayList<Character> chars_arraylist = new ArrayList<Character>();
		for(int i = 0; i < chars.length; i++){
			chars_arraylist.add(chars[i]);
		}
		String alphabet = "abcdefghijklmnopqrstuvwxyz";
		for(int i=0; i < alphabet.length(); i++){
			Character c = alphabet.charAt(i);
			System.out.println(c +  " : " + get_count(chars_arraylist, c));
		}
	}

	private static Integer get_count(ArrayList<Character> chars_arraylist, Character c){
			Integer count = 0;
		if(chars_arraylist.indexOf(c) != -1){
			count = count + chars_arraylist.lastIndexOf(c) + 1 - chars_arraylist.indexOf(c);
		}
		Character upper_c = Character.toUpperCase(c);
		if(chars_arraylist.indexOf(upper_c) != -1){
			count = count + chars_arraylist.lastIndexOf(upper_c) + 1 - chars_arraylist.indexOf(upper_c);
		}
		return count;
	}

}

Measured memory_bytes: 21224
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());
		int diff = 0;
		long c = 0;
		for (int i = 0; i < n; i++) {
			diff += a[i];
			if (i % 2 == 0) {
				if (diff <= 0) {
					c += -diff + 1;
					diff = 1;
				}
			}
			else {
				if (diff >= 0) {
					c += diff + 1;
					diff = -1;
				}
			}
		}
		long ans = c;
		c = 0;
		diff = 0;
		for (int i = 0; i < n; i++) {
			diff += a[i];
			if (i % 2 != 0) {
				if (diff <= 0) {
					c += -diff + 1;
					diff = 1;
				}
			}
			else {
				if (diff >= 0) {
					c += diff + 1;
					diff = -1;
				}
			}
		}
		ans = Math.min(ans, c);
		System.out.println(ans);
	}
}

Measured memory_bytes: 48692
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divsor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}

int main(){
	ll n,p;cin>>n>>p;
	auto res=prime_factor(p);
	ll ans=1;
	for(auto p:res){
		while(p.second>=n){
			ans*=p.first;
			p.second-=n;
		}
	}
	cout<<ans<<endl;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll a,b,c,k,count=0;
  cin>>a>>b>>c>>k;
  if(b<=a) count = (ll)(log2(a/(b*1.0)))+1;
  
  b = b*((ll)(pow(2,count)));
  //cout<<count<<" "<<b<<"\n";
  if(c<=b) count += (ll)(log2(b/(c*1.0)))+1;
  if(count<=k) cout<<"Yes\n";
  else cout<<"No\n";
  //cout<<count;
                        
                       
                        }

Measured memory_bytes: 3812
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
const int MAXN = 1e5+20000;
const int MAXNk = 1e4+20;
const double eps = 1e-9;
const long long INF = 1e18;
using namespace std;
 
 

string s,t;
bool ans;
int n,l;
bool bol;
void dfs(int v)
{
	if (v  == n) ans = true;
	t = "dream";
	l = t.length();
	bol = false;
	if (v + l -1 >n-1) bol = true;
	for (int i=v; i<min(n,v+l); i++) if (t[i-v]!=s[i]) bol =true;
	if (!bol) dfs(v+l);
	
	
	t = "dreamer";
	l = t.length();
	bol = false;
	if (v + l -1 >n-1) bol = true;
	for (int i=v; i<min(n,v+l); i++) if (t[i-v]!=s[i]) bol =true;
	if (!bol) dfs(v+l);
	
	
	t = "erase";
	l = t.length();
	bol = false;
	if (v + l -1 >n-1) bol = true;
	for (int i=v; i<min(n,v+l); i++) if (t[i-v]!=s[i]) bol =true;
	if (!bol) dfs(v+l);
	
	
	t = "eraser";
	l = t.length();
	bol = false;
	if (v + l -1 >n-1) bol = true;
	for (int i=v; i<min(n,v+l); i++) if (t[i-v]!=s[i]) bol =true;
	if (!bol) dfs(v+l);
	
}

int main()
{
	ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
//	freopen("kotlin.in", "r", stdin);
//	freopen("kotlin.out", "w", stdout);
 

	cin>>s;
	n = s.length();
	dfs(0);
	if (ans) cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
}


Measured memory_bytes: 1360
unittest
{
	assert( [ "2 5", "1 WA", "1 AC", "2 WA", "2 AC", "2 WA" ].parse.expand.solve == "2 2" );
	assert( [ "100000 3", "7777 AC", "7777 AC", "7777 AC" ].parse.expand.solve == "1 0" );
	assert( [ "6 0" ].parse.expand.solve == "0 0" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto pss = new Tuple!( long, bool )[ nm[ 1 ] ];
	foreach( ref ps; pss )
	{
		input.popFront;
		auto z = input.front.split;
		ps[ 0 ] = z[ 0 ].to!( long ) - 1;
		ps[ 1 ] = ( z[ 1 ] == "AC" );
	}
	return tuple( nm[ 0 ], pss );
}

auto solve( long n, Tuple!( long, bool )[] pss )
{
	auto as = new bool[ n ];
	auto ws = new long[ n ];
	foreach( ps; pss )
	{
		if( as[ ps[ 0 ] ] ) continue;
		if( ps[ 1 ] ) as[ ps[ 0 ] ] = true;
		else          ws[ ps[ 0 ] ]++;
	}
	
	auto ac = 0L;
	auto wa = 0L;
	foreach( a, w; lockstep( as, ws ) )
	{
		ac += a;
		if( a ) wa += w;
	}
	return format( "%s %s", ac, wa );
}


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

int main(){
  string S;
  int a;
  int cnt;
  cin>>S;
  a=S.length();
  for(int i=0;i<a;i++){
    if(S[i]=='x')cnt++;
  }
  if(cnt>7){cout<<"NO"<<endl;}
  else{cout<<"YES"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Max(xx,yy) (xx > yy ? xx : yy);
#define Min(xx,yy) (xx < yy ? xx : yy);

using namespace std;
 
bool isDebug;
 
template<typename... T>
void dbg(T... args){
	if(!isDebug)
		return;
	
	#ifdef LOCAL
		((cout << args << " "), ...) << "\n";
	#endif
}
    
int main(int argc, char* argv[]){
	ios_base :: sync_with_stdio(false);
	cout.tie(NULL), cin.tie(NULL);
	isDebug = (argc > 1 && string(argv[1]) == "debug");
               
	long long n,k;
	cin >> n >> k;
	map<long long, bool> ok;
	for(int i = 1;i <= k;i++){
		long long m;
		cin >> m;
	 	for(int j = 1;j <= m;j++){
	 		int in;
			cin >> in;
			ok[in] = true;
		} 	
	}
	int ans = 0;
	for(int i = 1;i <= n;i++)
		ans += !ok[i];
	cout << ans;
}
    




Measured memory_bytes: 3656
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <string>  	
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define bublic public
#define kektor vector
#define pii pair<int, int>
#define pp pair
#define all(x) x.begin(), x.end()
#define rand() (rand() << 15)
    
using namespace std;
    
typedef long long ll;

     
int RandInt(int min, int max) {
    if (max < min) swap(min, max);
    random_device rd;                                                                                                                                                                        
    mt19937 mt(rd());
    uniform_int_distribution<int> dist(min, max);
    return dist(mt);
}
                                                                      
const int maxn = 3e5, mod = 1e9 + 7, inf = 1e9;

void solve() {
	int a, b, k; 
	cin >> a >> b >> k; 
	for (int i = a; i < min(b + 1, a + k); ++i) cout << i << '\n'; 
	for (int i = max(a + k, b - k + 1); i <= b; ++i) cout << i << '\n'; 
}                               
    
signed main() {
	srand(time(0)); 
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef offline_judge 
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    #endif   
    solve();
    return 0;                                        
}    

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]%2==0)
    {
      if (a[i]%3!=0&&a[i]%5!=0)
      {
        cout<<"DENIED";
        return 0;
      }
    }
  }
  cout<<"APPROVED";
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans_count = 0;

    for(int i=1; i<=n; i++) {
        int div_count = 0;
        for(int j=1; j <= i; j++) {
            if(i % j == 0 && i % 2 == 1) div_count++;
        }
        if(div_count == 8) ans_count++;
    }
    cout << ans_count << endl;
}


Measured memory_bytes: 3640
//
//  main.c
//  A
//
//  Created by s1262004 on 2019/07/26.
//  Copyright Â© 2019 s1262004. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
int N = 8;

int col[8];
int row[8];
int dpos[16];
int dneg[16];

int coord[8][8];

void printBoard();

int putQueen(int);
int isSafe(int, int);


int main(int argc, const char* argv[]) {
	int i, j;
	int n;

	for (i = 0; i < N; i++) {
		row[i] = col[i] = 0;
		for (j = 0; j < N; j++) coord[i][j] = dpos[i + j] = dneg[i - j + N - 1] = 0;
	}


	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		int tempRow, tempCol;

		scanf("%d %d", &tempRow, &tempCol);

		coord[tempRow][tempCol] = 1;

		row[tempRow] = col[tempCol] = 1;
		dpos[tempRow + tempCol] = dneg[tempRow - tempCol + N - 1] = 1;
	}

	if (!putQueen(0)) printf("No solution\n");
	return 0;
}

void printBoard() {
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			(coord[i][j]) ? printf("Q") : printf(".");
		}
		printf("\n");
	}
}

int putQueen(int i) {
	if (i >= N) {
		printBoard();
		return 1;
	}
	if (row[i]) { //already placed
		if (putQueen(i + 1)) return 1;
	}

	int j;
	for (j = 0; j < N; j++) {
		if (!isSafe(i, j)) continue;
		
		coord[i][j] = 1;
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = 1;

		if (putQueen(i + 1)) return 1;
		coord[i][j] = 0;
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = 0;
	}
	return 0;
}

int isSafe(int r, int c) {
	if (row[r] || col[c]) {
		return 0;
	}
	if (dpos[r + c]) {
		return 0;
	}
	if (dneg[r - c + N - 1]) {
		return 0;
	}
	return 1;
}



Measured memory_bytes: 2112
using System;

namespace peaks
{
    class Program
    {
        const int N = 100000;
        const int M = 100000000;
        static void Main(string[] args)
        {


            int n, m;
            int[] h = new int[M];
            int[]  ma= new int[N];

            string inD0=Console.ReadLine();
            string[] cngD0 = inD0.Split(' ');

            n= int.Parse(cngD0[0]);
            m= int.Parse(cngD0[1]);

            string inD1 = Console.ReadLine();
            string[] cngD1 = inD1.Split(' ');

            for (int i = 0; i <= n-1; i++){
                    h[i] = int.Parse(cngD1[i]);
                    ma[i] = 0;
            }
            for (int i = 0; i <= m-1; i++){
                    string inD2 = Console.ReadLine();
                    string[] cngD2 = inD2.Split(' ');

                int a = int.Parse(cngD2[0])-1;
                    int b= int.Parse(cngD2[1])-1; 
                    ma[a] = Math.Max(ma[a], h[b]);
                    ma[b] = Math.Max(ma[b], h[a]);
            }
            
            int ans = 0;
            for (int i = 0; i <= n-1; i++)
                {
                    if (h[i] > ma[i]){
                        ans += 1;
                    }
            }
            Console.WriteLine(ans);

        }


    }
}


Measured memory_bytes: 47616
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin >> N;
  vector<pair<long long,long long>> A(N);
  for(long long i=0; i<N; i++){
    long long a,b;
    cin >> a >> b;
    A[i].first = a+b;
    A[i].second = a-b;
  }
  sort(A.begin(),A.end());
  long long ans=0,n=-10000000000;
  for(long long i=0;i<N;i++){
    if(A[i].second >= n){
      ans++;
      n = A[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w,n;
  cin >> h >> w >>n;
  int mxx ,mix,may,miy;
   mxx = h;
   may = w;
   mix = 0;
   miy =0;
  for(int i =0;i<n;i++){
    int x,y,a;
    cin >> x >> y >> a;
    if( a == 1){
      mix = max(mix,x);
    }
    else if( a== 2){
      mxx = min(mxx,x);
    }
    else if(a==3){
      miy = max(miy,y);
    }
    else{
      may = min(may,y);
    }
  }
  if( mxx -mix>0&& may -miy>0){
    cout << (mxx -mix)*(may-miy);
  }
  else{
    cout << 0;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
  //static List<string> list;
  //static List<int> primes = new List<int>{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,
  //                              59,61,67,71,73,79,83,89,97};
	static void Main(string[] args)
	{
		// 入力フェーズ
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        // 処理
        int[] fav = new int[M+1]; // M個の食べ物の好き投票箱
        for(int i=0; i<N; i++)
        {
          // i番目の人に話を聞く
          string[] interview = Console.ReadLine().Split(' ');
          //Console.Write(interview[0] + " ");
          int K = int.Parse(interview[0]);
          for(int j=1; j<=K; j++)
          {
            int f = int.Parse(interview[j]);
            //Console.Write(f + " ");
            fav[f] += 1;
          }
          //Console.WriteLine(" ");
        }

        // 全員（N人）から得票した食べ物を数える
        int ret = 0;
        for(int i=1; i<=M; i++)
        {
          int f = fav[i];
          if(f==N)
          {
            ret ++;
          }
        }


    // 出力
        Console.WriteLine(ret + "");
    }
		class myClass{ //自作クラス
			public long total {set; get;} // 全部の層数
			public long paty {set; get;}  // パティの数
      public long banz {set; get;}  // バンズの数
		}

    static void myMethod(int arg)
    {

    }
}


Measured memory_bytes: 13140
a, b = map(int, input().split())
s = input()
new_s = s[:a]+s[a+1:]
if len(s) == a+b+1:
    if "-" in s[a]:
        for i in new_s:
            if "-" in i:
                print("No")
                exit()
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
  while (true)
  {
    int n, x; cin >> n >> x;
    if (n == 0 && x == 0) break;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      for (int j = i+1; j <= n; j++)
      {
        for (int k = j+1; k <= n; k++)
        {
          int y = i + j + k;
          if (y == x) cnt++;
        }
      }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (A + B < X || X < A) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}

	return 0;
}

Measured memory_bytes: 256
def resolve():
    H, W, K = map(int, input().split())
    G = [list(input()) for _ in range(H)]

    ans = [[None] * W for _ in range(H)]

    cnt = 1
    for h in range(H):
        for w in range(W):
            if G[h][w] == "#":
                ans[h][w] = cnt
                cnt += 1

    # 左から右
    for h in range(H):
        for w in range(1, W):
            if ans[h][w] is None:
                if ans[h][w - 1] is not None:
                    ans[h][w] = ans[h][w - 1]

    # 右から左
    for h in range(H):
        for w in range(W - 1)[::-1]:
            if ans[h][w] is None:
                if ans[h][w + 1] is not None:
                    ans[h][w] = ans[h][w + 1]
                    
    # 上から下
    for h in range(1, H):
        for w in range(W):
            if ans[h][w] is None:
                ans[h][w] = ans[h - 1][w]

    # 下から上
    for h in range(H - 1)[::-1]:
        for w in range(W):
            if ans[h][w] is None:
                if ans[h + 1][w] is not None:
                    ans[h][w] = ans[h + 1][w]

    for h in range(H):
        print(*ans[h])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13304
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  scanf("%lld", &N);
  if (N & 1) {
    puts("0");
    return 0;
  }
  ll ans = 0;
  ll d = 10;
  while (d <= N) {
    ans += N / d;
    d *= 5;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    string S;
    cin>>S;
    ll ans = INF;
    rep(i,0,26){
        ll sum = 0;
        ll summax = 0;
        v temp;
        rep(j,0,S.size()){
            if(S[j] != char('a'+i))sum++;
            else{
                temp.PB(sum);
                sum = 0;
            }
            temp.PB(sum);
        }
        sort(all(temp));
        ans = min(ans, temp[temp.size()-1]);
    }
    cout<<ans;
    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++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int ans=0;
    if(a<k){
        ans+=a;
        k-=a;
    }
    else {
        ans+=k;
        k=0;
    }
    if(k>0)k-=b;
    if(k>0){
        ans-=k;
        k-=c;
    }
    else {
        k-=c;
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3636
import java.io.PrintWriter
import kotlin.math.max

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

var gn = 0
var gm = 0
var gq = 0
var max = 0
var queries = emptyArray<List<Int>>()

fun solve(out: PrintWriter) {
    val (n, m, q) = readIntegerList()
    gn = n
    gm = m
    gq = q
    queries = Array(q) { readIntegerList() }
    dfs(emptyList<Int>(), 0)
    println(max)
}

fun dfs(list: List<Int>, count: Int): Int {
    if (count == gn) {
        return calc(list)
    }

    val from = if (list.isEmpty()) 1 else list.last()
    for (i in from..gm) {
        max = max(max, dfs(list + i, count + 1))
    }
    return max
}

fun calc(list: List<Int>): Int {
    var tmp = 0
    for (q in queries) {
        val (a, b, c, d) = q
        if (list[b - 1] - list[a - 1] == c) {
            tmp += d
        }
    }
    return tmp
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

int main() {
  int N; cin >> N;
  if(N/1000) puts("ABD");
  else puts("ABC");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,m;
  cin>>n>>m;
  int k[m];
  vector<vector<int>> s(m);
  int ts;
  int p[m];
  REP(i,m){
    cin>>k[i];
    REP(j,k[i]){
      cin>>ts;
      ts--;
      s[i].push_back(ts);
    }
  }
  REP(i,m){
    cin>>p[i];
  }
  int ans=0;
  int cnt=0;
  bool flag=true;
  for(int i=0;i<(1<<n);i++){//スイッチのon/offを全通り試す。
    REP(j,m){//ある電球がonかどうかを確かめる。
      for(int r=0;r<k[j];r++){//電球jにつながっているスイッチでonになっているものを数える。
        if(i>>s[j][r] & 1){
          cnt++;
        }
      }
      if(cnt%2==p[j]){//電球jが点灯している場合
        cnt = 0;
        continue;
      }else{
        cnt = 0;
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }else{
      flag = true;
    }
  }
  
  cout<<ans<<endl;
        
        
        
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << setprecision(11) << sqrt(pow(x2-x1,2)+pow(y2-y1,2)) << endl;
 
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n,x;
  scanf("%d%d",&n,&x);
  vi a(n);
  cin>>a;
  sort(rng(a));
  rep(i,n) {
    if (x < a[i]) {
      cout<<i<<endl;
      return 0;
    }
    x -= a[i];
  }
  cout<<n-!!x<<endl;
  return 0;
}






















Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){

  int N; cin >> N;
  ll DP[10][10] = {0};

  for (int i = 1; i <= N; i++){
    int now = i;
    int back = now % 10;

    while (now > 9){
      now /= 10;
    }
    DP[now][back]++;
  }

  ll ans = 0;
  for (int i = 0; i < 10; i++){
    ans += DP[i][i] * DP[i][i];
    for (int j = i + 1; j < 10; j++){
      ans += DP[i][j] * DP[j][i] * 2;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256