akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let s2 = s.to_uppercase();
    if s == s2 {
        println!("A");
    } else {
        println!("a");
    }
}


Measured memory_bytes: 2164
#include <stdio.h>

int N;
int a[128];

int main(void) {
	int i;
	int mizuhasu = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if ((i + 1) % 2 != 0 && a[i] % 2 != 0) mizuhasu++;
	}
	printf("%d\n", mizuhasu);
	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
 
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  rep(i,n){
    cin >>a[i].first;
    a[i].second=i+1;
  }
  sort(all(a));
  rep(i,n){
    cout <<a[i].second << " ";
  }
}

Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N,M;
    cin >> N >> M;
    int ans = (int)pow(2,M)*(1900*M+(N-M)*100);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)

int N,Q;
int n;
const int maxn = 200005;

long long sum[maxn<<1];
long long lazy[maxn<<1];

long long init(int p,int l,int r){
    if(l == r){
        return sum[p];
    }
    int mid = (l+r)/2;

    init(p<<1,l,mid);
    init(p<<1|1,mid+1,r);
    sum[p] = sum[p<<1] + sum[p<<1|1];
    return sum[p];
}

void push_down(int p,int L,int R){
    long long l = lazy[p];
    int mid = (R+L)/2;
    if(lazy[p]){
        lazy[p<<1] += l;
        lazy[p<<1|1] += l;
        sum[p<<1]+= l*(mid-L+1);
        sum[p<<1|1]+= l*(R-mid);
        lazy[p] = 0;
    }
}

void update(int p,int l,int r,int L,int R,int num){
    if(l<= L && r>=R){
        lazy[p] += num;
        sum[p] += (R-L+1)*(long)num;
        return;
    }

    //printf("%d %d %d %d\n",r,L,l,R);
    if(l > R || r < L) return;
    push_down(p,L,R);
    int mid = (L+R)/2;
    update(p<<1,l,r,L,mid,num);
    update(p<<1|1,l,r,mid+1,R,num);
    sum[p] = sum[p<<1] + sum[p<<1|1];
}

long long query(int p,int l,int r,int L,int R){
    if(l <= L && r>= R){
        return sum[p];
    }
    if(l > R || r < L) return 0;
    push_down(p,L,R);
    int mid = (L+R)/2;
    return query(p<<1,l,r,L,mid) + query(p<<1|1,l,r,mid+1,R);
}

int main()
{
     scanf("%d %d",&N,&Q);
     n = 1;
     while(n < N) n*=2;

    /*
    _for(i,0,N){
        scanf("%lld",&sum[i+n]);
     }

     init(1,0,n-1);
    */
     _for(i,0,Q){
        string s;
        int beg,ed,num;
        cin >> s >> beg >> ed;
        if(s == "1"){
            printf("%lld\n",query(1,beg-1,ed-1,0,n-1));
            //printf("OK");
        }
        else if(s == "0"){
            cin >> num;
            update(1,beg-1,ed-1,0,n-1,num);
        }
     }

    //printf("%d\n",n);
    //_for(i,0,n<<1) printf("%lld ",sum[i]);

    return 0;
}



Measured memory_bytes: 6400
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL A, B;
int P[5011];
int R[5011];
LL dp[5011][5011]; // 200MB

int low[5011];

void MAIN() {
    scanf("%d%lld%lld", &N, &A, &B);
    REP (i, N) scanf("%d", P+i), P[i]--;
    REP (i, N) R[P[i]] = i;

    memset(dp, 0x3f, sizeof dp);
    REP (i, N+1) {
	dp[i][0] = 0;
	dp[0][i] = 0;
	dp[1][i] = 0;
    }

    for (int i=1; i<=N; i++) {
	REP (k, i) if (P[k] > P[i-1]) low[P[k]]++;

	for (int h=1; h<N; h++) {
	    if (i-1 <= R[h]) {
		dp[i][h] = dp[i][h-1];
	    } else {
		amin(dp[i][h], dp[i][h-1] + A);
		amin(dp[i][h], dp[R[h]][h-1] + low[h] * B);
	    }
	}
    }

    printf("%lld\n", dp[N][N-1]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int num[50][26];

int main(void){
	int n;
	cin >> n;
	rep(i,n){
		string s;
		cin >> s;
		for(auto &c:s) num[i][c-'a']++;
	}

	string ans="";
	rep(i,26){
		int len=55;
		rep(j,n) chmin(len,num[j][i]);
		ans+=string(len,'a'+i);
	}	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DFriends solver = new DFriends();
        solver.solve(1, in, out);
        out.close();
    }

    static class DFriends {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            UnionFind uf = new UnionFind(n);
            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1, b = in.nextInt() - 1;
                uf.union(a, b);
            }

            int answer = 0;
            for (int i = 0; i < n; i++) {
                answer = Math.max(answer, uf.size(i));
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class UnionFind {
        private final int[] __rep;
        private final int[] __size;

        public UnionFind(int n) {
            __rep = new int[n];
            __size = new int[n];
            for (int i = 0; i < n; i++) {
                __rep[i] = i;
                __size[i] = 1;
            }
        }

        public int rep(int x) {
            if (__rep[x] == x) {
                return x;
            }

            int r = rep(__rep[x]);
            __rep[x] = r;
            return r;
        }

        public int size(int x) {
            return __size[rep(x)];
        }

        public boolean union(int x, int y) {
            x = rep(x);
            y = rep(y);

            if (x == y) {
                return false;
            }

            if (size(x) < size(y)) {
                int t = x;
                x = y;
                y = t;
            }

            // now size(x) >= size(y)

            __rep[y] = x;
            __size[x] += __size[y];
            return true;
        }

    }
}



Measured memory_bytes: 49180
z = [0, 0, 0, 0]
inp = input()
for i in range(4):
    z[i] = int(inp[i])
res = 0
out = ""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if(res == 7):
                break
            res = 0
            if(i == 0):
                out = str(z[0]) + "+" + str(z[1])
                res = z[0] + z[1]
            else:
                out = str(z[0]) + "-" + str(z[1])
                res = z[0] - z[1]

            if(j == 0):
                out += "+" + str(z[2])
                res += z[2]
            else:
                out += "-" + str(z[2])
                res -= z[2]

            if(k == 0):
                out += "+" + str(z[3])
                res += z[3]
            else:
                out += "-" + str(z[3])
                res -= z[3]
print(out + "=7")

Measured memory_bytes: 3064
n = int(input())
a,b = [] ,[]
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
ab = zip(a,b)
ab = sorted(ab)
a,b = zip(*ab)

print(a[-1] + b[-1])

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

#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)
#define PI 3.14159265


typedef long long ll;

bool myCmp(pair<int,string> &p1 , pair<int,string>&p2)
{
    if(p1.first == p2.first)
        return p1.second<p2.second;
    else return p1.first > p2.first;
}
unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str)
{
    int num;
    std::istringstream iss(str); //put string in input stream
    iss >> num; return num; //read from stream as integer
}
ll  OO = 10e9;
const int MAXN = 2*10e5 +1;

map<string,int> m;
vector<pair<int,string>> vsi;
int main() {
    IOS();
    int N;
    cin>>N;
    string s;
    REP(i,N)
    {
        cin>>s;
        m[s]++;
    }
    vsi.resize(m.size());
    int i = 0 ;
    for(auto v : m)
    {
        vsi[i] = make_pair(v.second,v.first);
        ++i;
    }
    sort(vsi.begin(),vsi.end(),myCmp);
    int score = vsi[0].first;
    for(int k = 0; k<vsi.size();++k)
    {
        if(vsi[k].first == score)
            cout<<vsi[k].second<<endl;
        else
            break;
    }
    return 0;
}


Measured memory_bytes: 27008
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    if s[-1]=="s":
        print(s+"es")
    else:
        print(s+"s")

        
        
        
        



        
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 67196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <bitset>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const llint inf = 1 << 29 ;

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

	rep1(i, 9) {
		if (n % i == 0 && 1 <= n / i && n / i <= 9) { cout << "Yes" << endl; return 0;}
	}

	cout << "No" << endl;
	
}
  

Measured memory_bytes: 256
N = gets.to_i
xs = gets.strip.split(' ').collect{|x| x.to_i}.zip(0...N).sort

is = []
xs.zip(0...N){|(n, i), j|
	is[i] = j
}

N.times{|i|
	if is[i] < N / 2
		j = N / 2
	else
		j = N / 2 - 1
	end
	puts xs[j][0]
}


Measured memory_bytes: 40444
N = int(input()) #number of robots

robo_list = []
for i in range(N):
    robo_list.append(list(map(int, input().split())))

robo_list.sort()
#print(robo_list)

xmax = 0
counter = 0
for i in range(N):
    if(i==0):
        robo = robo_list[i]
        xmax = robo[0]+robo[1]
        counter += 1
    else:
        robo = robo_list[i]
        if(robo[0]-robo[1] >= xmax):
            xmax = robo[0]+robo[1]
            counter += 1
        else:
            if(robo[0]+robo[1] <= xmax):
                xmax=robo[0]+robo[1]
                
    
print(counter)

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

int main(){
    double x1, x2, y1, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
}


Measured memory_bytes: 3232
#include<stdio.h>
int a[3000][2];
int main(){
int i;
for(i=0;i<3000;i++){
for(int k=0;k<2;k++){
scanf("%d",&a[i][k]);}
int temp;
if(a[i][0]>a[i][1]){
temp = a[i][0];
a[i][0] = a[i][1];
a[i][1] = temp;
}
if(a[i][0] == 0 && a[i][1] == 0)
break;
}

for(int j=0;j<i;j++){
printf("%d %d\n",a[j][0],a[j][1]);
}
return 0;
}


Measured memory_bytes: 2116
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
	int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, c5, c6, c7, c8, c9, t1, t2, t3, t4, t5, t6, y1, y2, y3, y4, y5, y6;

	cin >> c1 >> c2 >> c3;
	cin >> c4 >> c5 >> c6;
	cin >> c7 >> c8 >> c9;

	t1 = c2 - c1;
	t2 = c5 - c4;
	t3 = c8 - c7;
	t4 = c3 - c2;
	t5 = c6 - c5;
	t6 = c9 - c8;

	y1 = c4 - c1;
	y2 = c5 - c2;
	y3 = c6 - c3;
	y4 = c7 - c4;
	y5 = c8 - c5;
	y6 = c9 - c6;

	if (t2-t1==t3-t2&&t5-t4==t6-t5&&y2 - y1 == y3 - y2&&y5 - y4 == y6 - y5) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,0,K)sum+=P[i];
  Out(sum);
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string s, t;
	cin >> s >> t;
	int n1 = s.size();
	int n2 = t.size();
	int minC = INT_MAX;
	for(int i = 0; i <= n1 - n2; i++) {
		string str = s.substr(i, n2);
		int misMatch = 0;
		for(int j = 0; j < n2; j++) {
			if(str[j] != t[j]) misMatch += 1;
		}
		minC = min(misMatch, minC);
	}
	cout << minC;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <bitset>
#define ll long long
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define hurry ios::sync_with_stdio(false)
#define PI 3.141592654
#define xx (int) 1e5+7
//1546
using namespace std;

unsigned long long N,k,all,mins;
string s;
unsigned long long dp[22][22][2];

string conv(ll N)
{
    string ans="";
    while(N)
    {
        int dig=N%10;
        N/=10;
        ans+=(char)(dig+'0');
    }
    reverse(ans.begin(),ans.end());
    return ans;
}

ll doit(int i,int last,bool changed)
{
    if(i==all) return 1;
    unsigned long long &ret=dp[i][last][changed];
    if(ret!=-1) return ret;
    ret=0;
    if(i==0)
    {
        int r,l=(all==1)?0:1;
        if(all==s.size()) r=s[0]-'0';
        else r=9;
        for(int i=l;i<=r;i++)
        {
            ret+=doit(1,i,i<r);
        }
    }
    else
    {
        int dig=s[i]-'0';
        if(changed || all<s.size())
        {
            ret+=doit(i+1,last,1);
            if(last+1<10) ret+=doit(i+1,last+1,1);
            if(last) ret+=doit(i+1,last-1,1);
        }
        else
        {
            if(last<=dig) ret+=doit(i+1,last,last<dig);
            if(last-1<=dig && last) ret+=doit(i+1,last-1,last-1<dig);
            if(last+1<=dig && last+1<10) ret+=doit(i+1,last+1,last+1<dig);
        }
    }
    return ret;
}

bool check(ll mid)
{
    if(mid<N) return 0;
    s=conv(mid);
    unsigned long long t=0;
    for(int i=1;i<=s.size();i++)
    {
        memset(dp,-1,sizeof dp);
        all=i;
        t+=doit(0,0,0);
    }
    t-=mins;
    return t>=k;
}

int main()
{
    hurry;
    cin>>k;
    N = 0;
    s=conv(N);
    for(int i=1;i<=s.size();i++)
    {
        memset(dp,-1,sizeof dp);
        all=i;
        mins+=doit(0,0,0);
    }
    if(N==0) mins++;
    N++;
    unsigned long long first=0,last=8e18,mid,ans=-1;
    while(first<=last)
    {
        mid=(first+last)/2;
        if(check(mid))
        {
            ans=mid;
            last=mid-1;
        }
        else first=mid+1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    int ans;
    if(b % a == 0){
        ans = a + b;
    }else{
        ans = b - a;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e14, cnt;


ll mark[20000000];
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	
	ll maxB = 0; 
    for (ll i = 0; i < n; i++) 
        if (a[i] > maxB) 
            maxB = a[i]; 
            
   
    
    for (ll i = 0; i < n; i++)
        for (ll x = a[i]; x <= maxB; x += a[i])
            mark[x]++; 

  

    for (ll i = 0; i <n; i++){
    	if(mark[a[i]]<=1){
    		ans++;
    	}
    }
    cout<<ans<<endl;
}
	


Measured memory_bytes: 12980
#include<bits/stdc++.h>
#define debug printf("%d %s\n",__LINE__,__FUNCTION__)
typedef long long ll;
typedef std::pair<int,int> pii;
#define pb push_back
#define mk make_pair
#define fi first
#define se second

int _w;FILE* _f;

using namespace std;

char s[5];

int lst=1,ans=0;

int main(){
    scanf("%s",s+1);
    for(int i=2;i<=4;i++){
        if(s[i]!=s[lst]){
            if(s[lst]=='R'){
                ans=max(ans,i-lst);
            }
            lst=i;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int SL[300010];
int SR[300010];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    char c;
    cin >> c;
    if (c == 'E') {
      SL[i + 1] = SL[i];
      SR[i + 1] = SR[i] + 1;
    } else {
      SL[i + 1] = SL[i] + 1;
      SR[i + 1] = SR[i];
    }
  }

  int ans = 1e9;
  for (int i = 0; i < N; i++) {
    int s = SL[i];
    s += SR[N] - SR[i + 1];
    ans = min(ans, s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2688
N = int(input())
S1 = input()
S2 = input()
MOD = 10 ** 9 + 7
if S1[0] == S2[0]:
  ans = 3
  i = 1
  f = True
else:
  ans = 6
  i = 2
  f = False

while i < N:
  if S1[i] == S2[i]:
    if f:
      ans = ans * 2 % MOD
    f = True
    i += 1
  else:
    if f:
      ans = ans * 2 % MOD
    else:
      ans = ans * 3 % MOD
    f = False
    i += 2

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define BIG 998244353
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;


int main() {
    int n,k;
    cin >> n >> k;
    cout << (n - k + 1) << endl;
}




Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, m, a, b, g[5000];
vector<int>v[5000],v2[5000];
set<int>st;
int cnt[5000];
bool TMJN[5000];
vector<iP>vp;

int dfs2(int x) {
	TMJN[x] = true;
	cout << x+1 << endl;
	rep(v[x].size())
		cnt[v[x][i]]++;
	rep(v[x].size()) {
		if (v2[v[x][i]].size() == cnt[v[x][i]] && !TMJN[v[x][i]])
			dfs2(v[x][i]);
	}
	return 0;
}


int main() {
	cin >> n >> m;
	rep(m) {
		cin >> a >> b;
		v[a - 1].push_back(b - 1);
		v2[b - 1].push_back(a - 1);
	}
	rep(n)
		g[i] = 0;
	rep(n) {
		REP(n, j) {
			REP(v[j].size(), k) {
				g[v[j][k]] = max(g[v[j][k]], g[j] + 1);
			}
		}
	}

	rep(n) {
		if (st.find(g[i]) != st.end())
			break;
		st.insert(g[i]);
	}
	if (st.size() == n) {
		int ans[5000];
		rep(n)
			ans[g[i]] = i + 1;
		rep(n)
			cout << ans[i] << endl;
		cout << 0 << endl;
		return 0;
	}
	rep(n) {
		cnt[i] = 0;
		TMJN[i] = false;
		vp.push_back(mkp(v2[i].size(), i));
	}
	sort(vp.begin(), vp.end());
	rep(n) {
		if (!TMJN[vp[i].second])
			dfs2(vp[i].second);
	}
	cout << 1 << endl;
	return 0;
}



Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


struct kouji{
    int s,t,x;
};

bool comp(kouji a,kouji b){
    return a.x < b.x;
}

signed main(){
    int n,q;
    cin >> n >> q;
    kouji A[n];
    REP(i,n){
        cin >> A[i].s >> A[i].t >> A[i].x;
    }

    sort(A, A+n, comp);

    set< pair<int, int>> S;
    REP(i,q){
        int tmp;
        cin >> tmp;
        S.insert( mp(tmp,i) );
    }

    int ans[q];
    REP(i,q) ans[i] = -1;
    REP(i,n){
        int l = A[i].s - A[i].x;
        int r = A[i].t - A[i].x;
        auto itr = S.lower_bound( mp(l, -1) );
        vector<int> dame;
        while( itr != S.end() and itr->fi < r  ){
            ans[ itr->se ] = A[i].x;
            S.erase(itr ++);
        }
    }

    REP(i,q){

        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 20608
N, W = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for i in range(W+1)] for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if L[N-i-1][1] > j:
            dp[N-i-1][j] = dp[N-i][j]
        else:
            dp[N-i-1][j] = max(dp[N-i][j], dp[N-i][j-L[N-i-1][1]] + L[N-i-1][0])

res = -1
for i in range(W+1):
    for j in range(N+1):
        res = max(res, dp[j][i])

print(res)


Measured memory_bytes: 24744
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	cin >> N >> K;
	int num;
	rep(i, N) {
		cin >> num;
	}
	if ((N - 1) % (K - 1) == 0) cout << (N - 1) / (K - 1);
	else cout << (N - 1) / (K - 1) + 1;
}



Measured memory_bytes: 256
def count_dot(lis):
    c=0
    for i in lis:
        if not(i=='.'):
            return c
        c+=1

def solve(N):
    a=[]
    dot =[]
    for i in range(N):
        a.append([char for char in input()])
        dot.append(count_dot(a[i]))

    for i in range(N):
        for j in range(len(a[i])):
            if a[i][j]=='.':
                a[i][j]=' '

    for i in range(1,N):
        #print(type(dot[i]))
        a[i][dot[i]-1]='+'
        k=1
        while True:
#            print(i-k,dot[i]-1)
            if a[i-k][dot[i]-1] == ' ':
                a[i-k][dot[i]-1]='|'
                k += 1
            else:
                break

    for i in range(N):
        for char in a[i]:
            print(char,end='')
        print()

while True:
    N=int(input())
#    print(N)
    if N==0:
        break
    solve(N)



Measured memory_bytes: 11632
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    int ans=0;
    rep(i,n-1){
        repi(j,i+1,n){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans;
}

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

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n+1,1);
	for(int i = 1; i <= k; i++){
		int d; cin >> d;
		for(int j = 0; j < d; j++){
			int x; cin >> x;
			a[x] = 0;
		}
	}
	int sum = 0;
	sum  = accumulate(a.begin(),a.end(),0);
	cout << sum - 1 << "\n";
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool f[250][250];
int d[250][250][6];

int main(){
  int sx,sy,gx,gy,n;
  cin>>sx>>sy>>gx>>gy>>n;
  sx += 120; sy += 120; gx += 120; gy += 120;
  fill(f[0], f[250], true);
  rep(i,n){
    int x,y;
    cin>>x>>y;
    x += 120; y += 120;
    f[x][y] = false;
  }

  int lx,ly;
  cin>>lx>>ly;

  auto ok = [&](int i, int j){
    return i>=120-lx && i<=120+lx && j>=120-ly && j<=120+ly && f[i][j];
  };

  const int dx[2][7] = {
    {0,1,1,0,-1,-1,0},
    {0,1,1,0,-1,-1,0}
  },
  dy[2][7] = {
    {1,0,-1,-1,-1,0,0},
    {1,1,0,-1,0,1,0}
  };

  using S = tuple<int,int,int>;
  fill(d[0][0], d[250][0], INF);
  d[sx][sy][0] = 0;
  queue<S> q;
  q.push(S{sx,sy,0});
  while(!q.empty()){
    int x,y,t;
    tie(x,y,t) = q.front(); q.pop();

    int nt = (t+1)%6;
    int k = abs((x-120)*(y-120)*t)%6;

    rep(i,7){
      int nx = x + dx[x%2][i], ny = y + dy[x%2][i];
      int nd = d[x][y][t];
      if(i!=k) nd++;
      if(ok(nx,ny) && d[nx][ny][nt] > nd){
        d[nx][ny][nt] = nd;
        q.push(S{nx,ny,nt});
      }
    }
  }

  int ans = INF;
  rep(i,6) ans = min(ans, d[gx][gy][i]);
  if(ans == INF) ans = -1;

  cout << ans << endl;


  return 0;
}

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

using namespace std;

int main(void){
	string w[2] = {"No","Yes"};
	string s;
	int flag = 1;
	cin >> s;
	for(int i=0;i<s.length();++i){
		if(i%2 == 0){
			if(s[i] == 'L'){
				flag = 0;
			}
		}else{
			if(s[i] == 'R')flag = 0;
		}
	}
	cout << w[flag] << endl;
}

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

int main(void) {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i = 0; i < B; i++) {
    for (int j = 0; j < A; j++) {
      cout << 0;
    }
    for (int j = A; j < W; j++) {
      cout << 1;
    }
    cout << endl;
  }
  for (int i = B; i < H; i++) {
    for (int j = 0; j < A; j++) {
      cout << 1;
    }
    for (int j = A; j < W; j++) {
      cout << 0;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int d,g;
int p[11],c[11],all[11];
bool flag[11];
int ans=MAX;

void check(){
	//cout<<"check start"<<endl;
	ll tmp=0,num=0;
	for(int i=1;i<=d;i++){
		if(flag[i]){
			tmp+=all[i];
			num+=p[i];
			//cout<<"complete:"<<i<<endl;
		}
	}
	//cout<<"score:"<<tmp<<endl;
	//cout<<"num:"<<num<<endl;
	for(int i=d;i>0;i--){
		if(tmp >= g)break;
		if(!flag[i]){
			//cout<<p[i]*i*100<<endl;
			if(g-tmp <= p[i]*i*100){
				num+=(g-tmp+i*100-1)/(i*100);
				tmp=g;
				break;
			}
		}
	}
	//cout<<"result num:"<<num<<endl<<endl;
	if(tmp >= g && ans > num)ans=num;
}
void func(int id){
	if(id == (d+1)){
		check();
		return;
	}
	flag[id]=false;
	func(id+1);
	flag[id]=true;
	func(id+1);

}

int main(void){
	cin>>d>>g;
	rep(i,d){
		int c;
		cin>>p[i+1]>>c;
		flag[i+1]=false;
		all[i+1]=p[i+1]*100*(i+1)+c;
	}
	func(1);
	cout<<ans<<endl;
	return 0;

}


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

int n, m, x;
long long ans;
priority_queue<int> pq;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	while(n--) {
		cin >> x;
		pq.push(x);
	}
	while(m--) {
		int x = pq.top();
		pq.pop();
		pq.push(x >> 1);
	}
	while(pq.size()) {
		ans += pq.top();
		pq.pop();
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 892
n=int(input())
ali=list(map(int,input().split()))
bli=list(map(int,input().split()))
ans=0
for i in range(n):
	ans+=min(ali[i]+ali[i+1],bli[i])
	ali[i+1]=max(0,ali[i+1]+min(ali[i]-bli[i],0))
print(ans)

Measured memory_bytes: 18476
#include <stdio.h>

void reverse(int n, int x[]) //数列を逆にする関数
{

    for (int i = 0; i < n / 2; i++)
    {
        int tmp = x[i];
        x[i] = x[n - 1 - i];
        x[n - 1 - i] = tmp;
    }
}

void print(int n, int x[]) //数列を表示する関数
{
    for (int i = 0; i < n - 1; i++)
    {
        printf("%d ", x[i]);
    }
    printf("%d\n", x[n - 1]);
}

int main(void)
{
    int n;
    int x[1000];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) //入力した回数だけ入力を繰り返す
    {
        scanf("%d", &x[i]);
    }

    reverse(n, x);
    print(n, x);

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  string s;

  for(int hi = 0; hi < H; hi++) {
    for(int wi = 0; wi < W; wi++) {
      cin >> s;
      if(s == "snuke") {
        cout << (char)(wi+65) << hi+1 << endl;
        return 0;
      }
    }
  }
}

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

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

//---main---------------------------------------------
int main(){
    //main
    string S;
    cin >> S;

    cout << S.substr(0,3) << endl;

    return 0;
}

Measured memory_bytes: 3624
S = input()
bool = 0
k = len(S)
for i in range(k):
  if i%2 == 0 and S[i] == 'L':
    bool = 1
  if i%2 == 1 and S[i] == 'R':
    bool = 1
if bool == 1:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 2940
import sys


def input(): return sys.stdin.readline().strip()


def main():
    S = input()

    odd = True
    for x in S:
        chars = 'RUD' if odd else 'LUD'
        if x not in chars:
            print('No')
            return
        odd = not odd
    print('Yes')


if __name__ == "__main__":
    main()


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

int main(){
    //入力
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    //出力
    cout << (char)toupper(s1.at(0)) << (char)toupper(s2.at(0)) << (char)toupper(s3.at(0)) << endl;
    
}

Measured memory_bytes: 256
s=list(input())
count=0
for i in range(3):
    if s[0]==s[i+1]:
        count+=1
if count==1:
    a=s[0]
    s.remove(a)
    s.remove(a)
    
    if s[0]==s[1]:
        print("Yes")
        
    else:
        print("No")
    
else:
    print("No")

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

public class Main{
	
	static Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int[] from,to;
		{
			String buf=s.next();
			from=new int[buf.length()+1];
			for(int i=0;i<buf.length();i++)
				from[i+1]=buf.charAt(i)=='A'?1:2;
			buf=s.next();
			to=new int[buf.length()+1];
			for(int i=0;i<buf.length();i++)
				to[i+1]=buf.charAt(i)=='A'?1:2;
			
			Arrays.parallelPrefix(from,(a,b)->a+b);
			Arrays.parallelPrefix(  to,(a,b)->a+b);
		}
		
		for(int q=s.nextInt();q>0;q--) {
			int f=-from[s.nextInt()-1]+from[s.nextInt()],
				t=-  to[s.nextInt()-1]+  to[s.nextInt()];
			System.out.println(f%3==t%3?"YES":"NO");
		}
	}
}


Measured memory_bytes: 107468
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n, m) = get!(usize, usize);
    let mut k = vec![0;m];
    let mut s = vec![0;m];
    for i in 0..m {
        let ks = get!(String);
        let mut iter = ks.split_whitespace();
        k[i] = iter.next().unwrap().parse::<usize>().unwrap();
        for next in iter.map(|e| e.parse::<usize>().unwrap()) {
            s[i] += 1 << (next-1);
        }
    }
    let p = get!([usize]);

    let mut count = 0;
    for i in 0..2usize.pow(n as u32) {
        let mut light = 0;
        for j in 0..m {
            let mut tmp = s[j] & i; 
            let mut cnt = 0;
            while tmp > 0 {
                cnt += tmp % 2;
                tmp /= 2;
            }
            if cnt%2 == p[j] {
                light += 1;
            } else {
                break;
            }
        }
        if light == m {
            count += 1;
        }
    }
    println!("{}", count);
            
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

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

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	cout <<(N+1)/2 <<endl;
	return 0;
}



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

int N, A, B;

int sum_n(int n){
    int sum=0;
    while(n != 0){
      sum += n%10;
      n = n/10;
    }
    return sum;
}

int main() {
    cin >> N >> A >> B;
    int sum=0, sum_N=0;
    for(int n=0;n<=N;n++){
      sum_N = sum_n(n);
      if( sum_N >= A && sum_N <= B ) sum += n;
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    const ll MOD = 998244353;
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i=0; i<N; i++) cin >> D[i];

    vector<int> C(N, 0);
    for(int i=0; i<N; i++){
        C[D[i]]++;
    }
    
    // for(int i=0; i<N; i++) cout << D[i] << " "; cout << endl;
    if(D[0] != 0){cout << 0 << endl; return 0;}
    if(C[0] > 1){cout << 0 << endl; return 0;}

    ll ans = 1;
    int M = N;
    for(int i=2; i<N; i++){
        if(C[i-1] == 0){
            M = i; break;
        }
        for(int j=0; j<C[i]; j++){
            ans *= C[i-1];
            ans %= MOD;
        }
    }
    for(int i=M; i<N; i++){
        if(C[i] != 0){
            cout << 0 << endl; return 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
V = LIST()

V = list(sorted(V))
V = [float(v) for v in V]


def sum_func(V):
    return (V[0] + V[1]) / 2


while True:
    if len(V) == 1:
        print(V[0])
        break
    else:
        V = [sum_func(V)] + V[2:]


Measured memory_bytes: 5180
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	n := nextInt()
	v := nextFloats(n)
	ans := 0.0

	sort.Float64s(v)

	for i := 1; i < len(v); i++ {
		v[i] = (v[i-1] + v[i]) / 2
	}
	ans = v[len(v)-1]

	//fmt.Fprintln(out, "[DEBUG]", d)
	fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640