akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  template<class Z> ModInt(Z x) : v(x >= 0 ? x % P : -x % P ? P - -x % P : 0) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { v = r.v < P - v ? v + r.v : v - (P - r.v); return *this; }
  M& operator-=(M r) { v = r.v <= v ? v - r.v : v + (P - r.v); return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  template<class Z> M pow(Z n) const {
    n = n >= 0 ? n % (P - 1) : P - 1 - -n % (P - 1);
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  template<class Z> friend M operator*(Z l, M r) { return M(l) *= r; }
  template<class Z> friend M operator/(Z l, M r) { return M(l) /= r; }
  template<class Z> friend M operator+(Z l, M r) { return M(l) += r; }
  template<class Z> friend M operator-(Z l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  template<class Z> friend bool operator==(Z l, M r) { return M(l) == r; }
  template<class Z> friend bool operator!=(Z l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  V<> a(26);
  for (char c : s) {
    ++a[c - 'a'];
  }
  Mint res = 1;
  for (int e : a) {
    res *= e + 1;
  }
  cout << res - 1 << '\n';
}

Measured memory_bytes: 512
import math

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

# print(X)

ans = 0

for i in range(N):
    for j in range(i + 1, N):
        x = 0
        for k in range(D):
            x += (X[i][k] - X[j][k]) ** 2

        if math.sqrt(x).is_integer():
            ans += 1

print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > jun(n);
    for(int i = 0;i < n;i++){
        int j;
        cin >> j;
        jun.at(i) = make_pair(j,i + 1);
    }

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

    for(int i = 0;i < n;i++){
        int a,b;
        tie(a,b) = jun.at(i);
        cout << b << endl;
    }

    return 0;
}


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

using namespace std;

int main(void){
    int N, L;
    cin >> N >> L;
    vector<int> aji(N);
    for(int i = 0; i < N; i++) aji[i] = L + i;
    int bite = L;
    for(int i = 0; i < N; i++){
        if(abs(aji[i]) < abs(bite)) bite = aji[i];
    }
    cout << accumulate(aji.begin(), aji.end(), 0) - bite << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        int counter = 0;
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextInt();
            if (h[i] >= k) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

Measured memory_bytes: 50164
#include <stdio.h>
using namespace std;
int a[60], n, sum;
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=1; i<n; i++)
        for(int j=i+1; j<=n; j++)
            sum += a[i]*a[j];
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, K; cin >> N >> K;

    double ans = 0.0;
    for(int i=1; i<=N; i++) {
        double add = 1.0 / N;
        int point = i;
        while(point < K) {
            point *= 2;
            add /= 2.0;
        }

        ans += add;
    }
    printf("%.12f\n", ans);
    return 0;
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

vector<ll> memo(1000007, INF);

int main() {

    int x, n;
    cin >> x >> n;

    int p[n];
    rep(i, n) {
        cin >> p[i];
    }

    int diff = 1000;
    int ans = -100;

    for (int i = -500; i <= 500; i++) {
        
        bool is = true;
        rep(j, n) {
            if (p[j] == i) {
                is = false;
            }
        }
        if (!is) continue;

        if (abs(i - x) < diff) {
            diff = abs(i - x);
            ans = i;
        }
    }

    AA(ans);

}

Measured memory_bytes: 11016
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t;
        int n;
        int i;
        
        for(i = 0;i<4;i++){
         t = scan.nextInt();
         n = scan.nextInt();
       if(t == 1){
           System.out.println(6000*n);
       }else if (t == 2){
           System.out.println(4000*n);
       }else if (t == 3){
           System.out.println(3000*n);
       }else if (t == 4){
           System.out.println(2000*n);
       }
       
       }
           }
        
    }




Measured memory_bytes: 26252
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define mx 1000000
using namespace std;

int main() {
  ios
  int t = 1;
  // cin>>t;
  while(t--) {
    ull n;
    cin>>n;
    ull a[n];
    unordered_map<ull,ull> h;
    for(ull i = 0;i < n;i++) cin>>a[i],h[a[i]]++;
    ull count = 0;
    for(ull i = 0;i < n;i++) {
      ull x = a[i];
      h[a[i]]--;
      bool found = false;
      for(ull j = 1;j*j <= x;j++) {
        if(x%j)
          continue;
        if(h[j] || h[x/j]) {
          found = true;
          break;
        }
        // while((x%j)==0)
        //   x=x/j;
      }
      count+=(!found);
      h[a[i]]++;
    }
    cout<<count;
    cout<<'\n';
  }
  return 0;
}

Measured memory_bytes: 33372
#include <stdio.h>  
#include <string.h>  
#include <queue>  
#include <algorithm>  
using namespace std;

const int maxn = 10050;
const int maxe = 2005000;
const int INF = 0x3f3f3f3f;

struct node
{
	int to;
	int w;
	int c;
	int next;
};
node edge[maxe];
int head[maxn];
int ip;

void addedge(int u, int v, int w, int c)
{
	edge[ip].to = v;
	edge[ip].c = c;
	edge[ip].w = w;
	edge[ip].next = head[u];
	head[u] = ip++;
}

int cost[maxn];
int dis[maxn];
bool vis[maxn];



void spfa(int s, int n)
{
	queue<int>q;
	for (int i = 1; i <= n; i++)
		cost[i] = dis[i] = INF;
	memset(vis, false, sizeof(vis));
	dis[s] = 0;
	cost[s] = 0;
	vis[s] = true;
	q.push(s);
	while (!q.empty())
	{
		int u = q.front();
		q.pop();
		vis[u] = false;
		for (int i = head[u]; i != -1; i = edge[i].next)
		{
			int to = edge[i].to;
			int val = edge[i].w;
			if (dis[to]>dis[u] + val || (dis[to] == dis[u] + val && cost[to]>edge[i].c))
			{
				dis[to] = dis[u] + val;
				cost[to] = edge[i].c;
				if (!vis[to])
				{
					q.push(to);
					vis[to] = true;
				}
			}
		}
	}
}

int main()
{
	int n, m;
	int u, v, w, c;
	while (scanf("%d%d", &n, &m) != EOF && n + m>0)
	{
		memset(head, -1, sizeof(head));
		ip = 0;
		for (int i = 0; i<m; i++)
		{
			scanf("%d%d%d%d", &u, &v, &c, &w);
			addedge(u, v, c, w);
			addedge(v, u, c, w);
		}
		spfa(1, n);
		int ans = 0;
		for (int i = 1; i <= n; i++)
			ans += cost[i];
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3544
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		
		
		int n=sc.nextInt();
		long a[]=new long[n];
		long b[]=new long[n];
		long taka[]=new long[n];
		long total=0L;
	
		for(int i=0;i<n;++i) {
			a[i]=sc.nextLong();
			b[i]=sc.nextLong();
			taka[i]=(a[i]+b[i])*1000000 + i;
		}
		Arrays.sort(taka);
		if(n%2==1) {
		for(int i=0;i<n;++i) {

			if (i%2==0)total=total+a[(int)(taka[i]%1000000)];
			else total=total-b[(int)(taka[i]%1000000)];
		}
		}
		else {
			for(int i=0;i<n;++i) {

				if (i%2==1)total=total+a[(int)(taka[i]%1000000)];
				else total=total-b[(int)(taka[i]%1000000)];
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 95428
import numpy as np
import math
import sys
import bisect
sys.setrecursionlimit(10000000)

def main():
    s = input()
    t = input()
    alphabets = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"), None)
    # alphabets = alphabet.copy()
    for key_ in alphabets:
        lists = []
        for i in range(len(s)):
            if key_ == s[i]:
                lists.append(i)
        alphabets[key_] = lists
    now = -1
    count = 0
    for alpha in t:
        if len(alphabets[alpha]) == 0:
            print(-1)
            sys.exit()
        else:
            lists = alphabets[alpha]
            index = bisect.bisect_right(lists, now)
            if index >= len(lists):
                now = -1
                count += len(s)
                now = lists[0]
            else:
                now = lists[index]
            # print(now, count)
    print(count + now + 1)
            







if __name__ == '__main__':
    main()

Measured memory_bytes: 16616
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef int ll;
using namespace std;
ll n,i,j,k,z,m,q,r,timer, cnt,v,tot,x,y,xx, yy,INF, sz;
vector<ll> mag;
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> m;
    if (n <= 0 && m >= 0) {
        cout << "Zero" << endl;
        return 0;
    }
    if (n > 0) {
        cout << "Positive" << endl;
        return 0;
    }
    int sum = m-n;
    if (sum%2==0)
        cout << "Negative" << endl;
    else
        cout << "Positive" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

ll count(bitset<15> mask, const vector<vector<ll>> test) {
	vector<ll> man(test.size());

	for (ll i = 0; i < test.size(); i++) {
		man[i] = mask[i];
	}

	for (ll i = 0; i < test.size(); i++) {
		bool truth = man[i];
		if (truth == 0) {
			continue;
		}

		for (ll j = 0; j < test.size(); j++) {
			ll t = test[i][j];
			if (t == -1) {
				continue;
			}
			if (man[j] != t) {
				return 0;
			}
		}
	}

	ll cnt = 0LL;
	for (auto&& e : man) {
		if (e) {
			cnt++;
		}
	}
	return cnt;
}

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

	vector<vector<ll>> test(n, vector<ll>(n, -1));

	for (ll i = 0; i < n; i++) {
		ll an;
		cin >> an;
		for (ll _ = 0; _ < an; _++) {
			ll ni, ai;
			cin >> ni >> ai;
			test[i][ni - 1] = ai;
		}
	}

	ll mx = 0LL;
	for (ll i = 0; i <= ((1LL << n) - 1); i++) {
		ll now = count(bitset<15>(i), test);
		mx = max(mx, now);
	}
	cout << mx << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			printf(" %d",i);
		}
		else {
			while (x) {
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}
				x /= 10;
			}
		}
	}
	printf("\n");
}



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

const int MOD=1000000007;
int n,m,fact[100001];
inline int _abs(int a) {return a<0 ? -a : a;}
int main() {
    scanf("%d%d",&n,&m);
    
    fact[0]=1;
    for(int i=1;i<=max(n,m);i++) fact[i]=1ll*fact[i-1]*i%MOD;
    if(n==m) printf("%lld\n",2ll*fact[n]%MOD*fact[m]%MOD);
    else if(_abs(n-m)==1) printf("%lld\n",1ll*fact[n]*fact[m]%MOD);
    else puts("0");
    return 0;
}


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    char str[1010];
    scanf("%s", str);
    int len = strlen(str);
    bool visited[4];
    reset(visited, false);
    FOR(i,len){
        if(str[i] == 'N')visited[0] = true;
        else if(str[i] == 'S') visited[1] = true;
        else if(str[i] == 'E') visited[2] = true;
        else if(str[i] == 'W')visited[3] = true;
    }

    if((visited[0]^visited[1])||(visited[2]^visited[3])){
        cout << "No";
    }else cout <<"Yes";


    return 0;
}





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

int main( void ) {
  int A, B, ans;
  cin >> A >> B;

  ans = A - 2*B;
  if ( ans < 0 ) {
    ans = 0;
  }

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


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	int x=0;
	for(int a=0;a<=n;a++){
		for(int b=0;b<=m;b++){
			if(m*a+n*b-2*a*b==k){
				x=1;
			}
		}
	}
	if(x==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var a = cin.nextlong;
        var b = cin.nextlong;
        var x = cin.nextlong;

        var l = b / x;
        var r = (a + x - 1) / x;

        WriteLine(l - r + 1);
        
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		Scanner sc = new Scanner(System.in);
		//FastReader sc = new FastReader();
		long n = sc.nextLong();
		long total =0 ;
		for(long i=1;i<=n;i++){
			if(i%3==0 || i%5==0){
				
			}else total+=i;
				
		}
		System.out.println(total);
		
	}
	
	
	/*public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o1.diff).compareTo(Long.valueOf(o2.diff));
		}
	}*/
		
	static class FastReader 
		{ 
		final private int BUFFER_SIZE = 1 << 16; 
		private DataInputStream din; 
		private byte[] buffer; 
		private int bufferPointer, bytesRead; 
  
		public FastReader() 
		{ 
			din = new DataInputStream(System.in); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public FastReader(String file_name) throws IOException 
		{ 
			din = new DataInputStream(new FileInputStream(file_name)); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public String readLine() throws IOException 
		{ 
			byte[] buf = new byte[64]; // line length 
			int cnt = 0, c; 
			while ((c = read()) != -1) 
			{ 
				if (c == '\n') 
					break; 
				buf[cnt++] = (byte) c; 
			} 
			return new String(buf, 0, cnt); 
		} 
  
		public int nextInt() throws IOException 
		{ 
			int ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do
			{ 
				ret = ret * 10 + c - '0'; 
			}  while ((c = read()) >= '0' && c <= '9'); 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public long nextLong() throws IOException 
		{ 
			long ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public double nextDouble() throws IOException 
		{ 
			double ret = 0, div = 1; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
  
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
  
			if (c == '.') 
			{ 
				while ((c = read()) >= '0' && c <= '9') 
				{ 
					ret += (c - '0') / (div *= 10); 
				} 
			} 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		private void fillBuffer() throws IOException 
		{ 
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
			if (bytesRead == -1) 
				buffer[0] = -1; 
		} 
  
		private byte read() throws IOException 
		{ 
			if (bufferPointer == bytesRead) 
				fillBuffer(); 
			return buffer[bufferPointer++]; 
		} 
  
		public void close() throws IOException 
		{ 
			if (din == null) 
				return; 
			din.close(); 
		} 
	} 
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pp pair< ll, pair<ll,ll> >

int main()
{
    ll a, b, c, d; cin>>a>>b>>c>>d;
    ll ans = max(a*c, a*d);
    ans = max3(ans, b*c, b*d);
    cout << ans << endl;
    return 0;
}


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += a[i] - 1;
		}		
		
		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 25320
def dfs(i,f):
    if i == 3:
        if eval(f) == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i+1,f+"-"+s[i+1])
        dfs(i+1,f+"+"+s[i+1])
s = input()
dfs(0,s[0])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
    using namespace std;
    #define MOD 1000000007
    //#define MOD 998244353
    const double EPS = 1e-9;
    #define INF (1LL<<60)
    #define D double
    #define fs first
    #define sc second
    #define int long long
    #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
    #define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
    #define REP(i,n)  FOR(i,0,(n))
    #define RREP(i,n) RFOR(i,0,(n))
    #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
    #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
    #define range(i,a,b) ((a)<=(i) && (i)<(b))
    #define debug(x)  cout << #x << " = " << (x) << endl;
    #define SP << " " << 
    typedef pair<int,int> P;
    typedef vector<int> vec;
    typedef vector<vector<int>> mat;

    void add(int &a, int b){
      a = ((a+b) % MOD + MOD) % MOD;
    }
    
    inline int mul(int a, int b) {
        add(a,0); add(b,0);
        #if !defined(_WIN32) || defined(_WIN64)
          return (int) ((long long) a * b % MOD);
        #endif
          unsigned long long x = (long long) a * b;
          unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
          asm(
            "divl %4; \n\t"
            : "=a" (d), "=d" (m)
            : "d" (xh), "a" (xl), "r" (MOD)
          );
          return m;
    }
    
    inline int modpow(int a, long long b) {
      int res = 1;
      while (b > 0) {
        if (b & 1) {
          res = mul(res, a);
          }
          a = mul(a, a);
          b >>= 1;
      }
      return res;
    }
    
    inline int inv(int a) {
        a %= MOD;
        if (a < 0) a += MOD;
        int b = MOD, u = 0, v = 1;
        while (a) {
          int t = b / a;
          b -= t * a; swap(a, b);
          u -= t * v; swap(u, v);
        }
        assert(b == 1);
        if (u < 0) u += MOD;
        return u;
    }
     
    signed main(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout.precision(20);
     
      int n;
      string s;
      cin >> n >> s;
      
      vec num(26, 0);

      REP(i, n){
        num[s[i] - 'a']++;
      }

      int ans = 1;
      REP(i, num.size()){
        ans *= num[i] + 1;
        ans %= MOD;
      }

      cout << (ans - 1 < 0 ? ans - 1 + MOD : ans - 1) << endl;

      return 0;
    }

Measured memory_bytes: 512
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    s=input()
    t=len(s)
    #文字数が同じなら通り数は一緒なので文字数だけ見る
    
    now=[0]*(N+5)
    nxt=[0]*(N+5)
    #i回操作して，j文字になる
    
    now[0]=1
    for i in range(N):
        for j in range(i+1):
            if j!=0:
                nxt[j-1]=(nxt[j-1] + now[j])%mod
            else:
                nxt[0]=(nxt[0]+now[0])%mod
            nxt[j+1]=(nxt[j+1] + 2*now[j])%mod
        for j in range(i+2):
            now[j]=nxt[j]
            nxt[j]=0
            
    
    temp=pow(2,t,mod)            
    ans=(now[t]*pow(temp,mod-2,mod))%mod
    print(ans)

main()


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

    ll s,w;
    cin>>s>>w;
    cout<<(w>=s?"unsafe":"safe")<<endl;

}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		for j,vol in enumerate(val):
			if tmp == vol:
				ans.append(2)
				break

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 84064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
using namespace std;
typedef long long LL;
typedef double ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int SIZE=2300;
VI edge[SIZE];
int A[SIZE],B[SIZE];
int N,K;
int dist[SIZE];
int solve(int a,int b){
	REP(i,N+1) dist[i]=INF;
	queue<int> qu;
	int times=0;
	qu.push(a);
	dist[a]=0;
	if(a!=b){
		qu.push(b);
		dist[b]=0;
	}
	while(!qu.empty()){
		int now=qu.front();
		times++;
		qu.pop();
		if(dist[now]==K) continue;
		REP(i,edge[now].size()){
			int next=edge[now][i];
			if(dist[next]==INF){
				dist[next]=dist[now]+1;
				qu.push(next);
			}
		}
	}
	return N-times;
}
int solveP(){
	int minium=INF;
	FOR(i,1,N+1)
		minium=min(minium,solve(i,i));
	return minium;
}
int solveE(){
	int minium=INF;
	REP(i,N-1)
		minium=min(minium,solve(A[i],B[i]));
	return minium;
}
int main(){
	cin >> N >> K;
	REP(i,N-1){
		cin >> A[i] >> B[i];
		edge[A[i]].PB(B[i]);
		edge[B[i]].PB(A[i]);
	}
	int isK=K&1;
	K/=2;
	if(isK) cout << solveE() << endl;
	else cout << solveP() << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int ans=1001,n,m; //cin>>d>>t>>s;
  string s,t;cin>>s>>t;
  
  n=s.length();
  m=t.length();
  
  rep(i,n-m+1){
    int memo=0;
    string sb=s.substr(i,m);
    rep(j,m)if(sb[j]!=t[j])memo++;
    
    ans=min(ans,memo);
  
  
  }
  
  
  
  cout<< ans<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

ll solve(ll x) {
    if(x % 2 == 0) {
        if((x + x % 2) / 2 % 2 == 1) {
            x = x ^ 1;
        }
    }else {
        if(((x + x % 2) / 2) % 2 == 1) {
            x = 1;
        }else {
            x = 0;
        }
    }
    return x;
}

int main() {
    ll A, B; cin >> A >> B;
    cout << (solve(A - 1) ^ solve(B)) << endl;
}


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



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

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

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

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class B {
public:
    void solve(std::istream &in, std::ostream &out) {
        string O, E;
        in >> O >> E;
        int no = sz(O), ne = sz(E);
        string res;
        FOR(i, 0, max(no, ne)) {
            if (i < no) {
                res += O[i];
            }
            if (i < ne) {
                res += E[i];
            }
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    B solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
/*  
    Walking down the street
    Distant memories
    Are buried in the past forever
    I follow the Moskva
    Down to Gorky Park
    Listening to the wind of change
    _________________________
    _________________________
    528 Hours of Solitude
    Quarantine_Day : 22
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)

ll n;
ll ara[100005];
ll dp[100005];

ll go(ll idx){
    if(idx == n - 1) return 0;
    else if(idx > n - 1) return 1000000;
    if(dp[idx] != -1) return dp[idx];
    int first;
    int second;

    first = abs(ara[idx + 1] - ara[idx]) + go(idx + 1);
    second = abs(ara[idx + 2] - ara[idx]) + go(idx + 2);

    return dp[idx]= min(first, second);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    REP(i, n) cin>>ara[i];
    memset(dp, -1, sizeof(dp));
    cout<<go(0)<<"\n";

    return 0;
}


Measured memory_bytes: 6528
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {

    var N = Number(lines[0].split(" ")[0])
    var ans = "";

    if (N === 0) { ans = 0; }
    else {
        while (N != 0) {
            if (N % 2 !== 0) {
                N--; ans = "1" + ans;
            }
            else {
                ans = "0" + ans;
            }
            N /= (-2);
        }
    }
    console.log(ans)
});

Measured memory_bytes: 7628
N, X, M = map(int, input().split())

tmp = [0 for i in range(M+2)]
r = [0 for i in range(M)]
tmp[1] = X
r[X] = 1 # A_1 = X
flag = False
for i in range(2, N+1):
  X = (X * X) % M
  #tmp[i] = tmp[i-1] + X
  tmp[i] = X
  if r[X] == 0:
    r[X] = i
  else:
    flag = True
    p = i - r[X]
    #pt = tmp[i] - tmp[r[X]]
    pt = 0
    for j in range(r[X]+1, i+1):
      pt += tmp[j]
    tmp_rX = 0
    for j in range(1, r[X]+1):
      tmp_rX += tmp[j]
    # ans = tmp[r[X]] + pt * ((N - r[X]) // p) + (N - r[X]) % p
    p_r = (N - r[X]) % p
    #T_r = tmp[r[X] + p_r] - tmp[r[X]]
    T_r = 0
    for j in range(1,p_r+1):
      T_r += tmp[ r[X] + j ]
    #ans = tmp[r[X]] + pt * ((N - r[X]) // p) + T_r
    ans = tmp_rX + pt * ((N - r[X]) // p) + T_r
    break
    
if flag:
  print(ans)
else:
  print(sum(tmp))

Measured memory_bytes: 13592
n=int(input())
s=input()
count=0
r_list=[]
g_list=[]
b_list=[]
for i in range(len(s)):
    if s[i]=="R":
        r_list.append(i)
    elif s[i]=="G":
        g_list.append(i)
    elif s[i]=="B":
        b_list.append(i)

for i in range(1,len(s)-1):
    if n%2==0:
        if i<n//2:
            for j in range(1,i+1):
                if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                    count+=1
        else:
            for j in range(1,n-i):
                if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                    count+=1
    else:
            if i<(n-1)//2:
                for j in range(1,i+1):
                    if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                        count+=1
            elif i==(n-1)//2:
                for j in range(1,n-i):
                    if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                        count+=1
            elif i>(n-1)//2:
                for j in range(1,n-i):
                    if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                        count+=1

print(len(r_list)*len(g_list)*len(b_list)-count)

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

int main(){
	int n;
	cin >> n;
	
	vector<int>v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	
	int ans = 1, tmp = 0, a = v[0];
	
	for(int i = 0; i < n; i++){
		if(a == 2) break;
		tmp = a - 1;
		a = v[tmp];
		
		ans++;
		
		if(a == 2) break;
		if(i == n - 1) ans = -1;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2112
use std::collections::VecDeque;


fn main() {
    let di: Vec<i32> = vec![0, 0, 1, -1];
    let dj: Vec<i32> = vec![1, -1, 0, 0];

    let mut sc = Scanner::new();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let map: Vec<Vec<char>> = (0..h).map(|_| sc.read::<String>().chars().collect()).collect();

    let mut deque = VecDeque::new();
    let mut costs = vec![vec![std::usize::MAX; w]; h];

    deque.push_front((0, 0));
    costs[0][0] = 1;
    while let Some((i, j)) = deque.pop_front() {
        for d in 0..4 {
            let ni = i as i32 + di[d];
            let nj = j as i32 + dj[d];
            if ni < 0 || nj < 0 { continue; }

            let ni = ni as usize;
            let nj = nj as usize;
            if ni >= h || nj >= w { continue; }

            if map[ni][nj] == '#' { continue; }
            if costs[ni][nj] <= costs[i][j] + 1 { continue; }

            costs[ni][nj] = costs[i][j] + 1;
            deque.push_back((ni, nj));
        }
    }

    if costs[h - 1][w - 1] == std::usize::MAX {
        println!("-1");
        return;
    }
    let mut count = 0;
    for i in 0..h { for j in 0..w { if map[i][j] == '.' { count += 1; } } }

    println!("{}", count - costs[h - 1][w - 1]);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
    cin>>a>>b;
    if( a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0) ){cout<<"YES";}
    else{cout<<"NO";}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;
int main(){
  int x;
  cin >> x;
  if(x == 2){
    cout << "2" ;
    return 0;
  }
  int parray[x];
  parray[0] = 2;
  int len = 0;
  bool flag;
  for(int i = 3; i <= x; i = i+2){
    flag = true;
    for(int j = 0; j <= len; j++){
      if(i%parray[j] == 0){
        flag = false;
        break;
      }
    }
   if(flag){
      len++;
      parray[len] = i;
      //cout << parray[len] << endl;
   }
  }
  int p = x%2 == 0 ? x+1 : x;
  int limit ;
 
  while(true){
    flag = true;
    limit = (int)sqrt((double)p);
    //cout << limit << endl;
    for(int i = 0; i <= limit+1; i++){
      if(p % parray[i] == 0){
        //cout << p << " " << parray[i] << endl;
        p = p+2;
        flag = false;
        break;
      }
    }
    if(flag){
      cout << p;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int r,g,b;
  cin >> r >> g >> b;
  int ans = 100*r + 10*g + b;
  if(ans%4 == 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
A = tuple(map(int, input().split()))
q = int(input())
B = tuple(map(int, input().split()))

memo = set()
for i in range(1, n + 1):
    for nums in itertools.combinations(A, i):
        memo.add(sum(nums))

for m in B:
    print('yes' if m in memo else 'no')


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

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

const ll llinf = (ll)1e18;
const int intinf = 1e9;
const int MOD =  (int)(1e9 + 7);
const ld EPS =  1e-7;


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

	vector <int> p(n), ans(n);

	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int cur = 0;

	for (int i = 0; i < n; i++) {
		cur ^= p[i];
	}

	for (int i = 0; i < n; i++) {
		cout << (cur ^ p[i]) << ' ';
	}

	cout << endl;

}

int main(){
	// freopen("input.txt", "result", stdin);
	// freopen("output.txt", "w", stdout);
	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: 4704
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll exception = 1;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 == 0) exception *= 2;
  }
  ll ans = pow(3LL, N) - exception;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4016
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,fa[1000001],x,y,ans;
int father(int a){
	if(fa[a]!=a)fa[a]=father(fa[a]);
	return fa[a];
}
int main(){
	scanf("%d%d",&n,&m);
	ans=n-1;
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		x=father(x);
		y=father(y);
		if(x!=y){
			fa[x]=y;
			ans--;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

int main(){
  LL ans=0;
  int N;
  cin >> N;
  LL D, A;
  cin >> D >> A;
  LL X[200010];
  LL H[200010];
  int num[200010];
  for(int i=0; i<N; i++){
    cin >> X[i] >> H[i];
    num[i]=i;
  }
  sort(num, num+N, [&X](size_t i1, size_t i2){
    return X[i1]<X[i2];
  });
  sort(X, X+N);
  for(int i=0; i<N; i++){
    if(H[num[i]]<=0) continue;
    else{
      LL k=(H[num[i]]+A-1)/A;
      if(X[N-1]-X[i]>2*D){
        ans+=k;
        for(int j=i; X[j]-X[i]<=2*D; j++) H[num[j]]-=k*A;
      }
      else{
        sort(H, H+N, greater<LL>());
        ans+=(H[0]+A-1)/A;
        break;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4096
def flatten_2d(data):
    for block in data:
        for elem in block:
            yield elem

a,k = map(int,input().split())
listA=[]
cnt=0
for i in range(k):
    n = int(input())
    string_list=list(map(int,input().split()))
    listA.append(string_list)
dst=list(flatten_2d(listA))
for cou in range(1,a+1):

    if cou not in dst:
        cnt+=1

print(cnt)

Measured memory_bytes: 68132
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll power(ll a,int n){
  ll res = 1,r = a;
  for (; n > 0;n>>=1,r*=r) res *= (n & 1? r:1);
  return res;
}
int main(){
  int n,k;
  cin >> n >> k;
  ll ans = 0;
  if(k%2){
    ans = power(n/k,3);
  }else{
    ans = power(n/k,3) + power(2*n/k - n/k,3);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline lli getint(){
    lli n;
    scanf("%lld",&n);
    return n;
}

inline vector<lli> getints(int n){
    vector<lli> a(n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    return a;
}

inline string getstr(){
  string s;
  cin>>s;
  return s;
}

inline string slice(string s,int a,int b){
  return s.substr(a,b-a-1);
}
void dumpints(vector<lli> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  int H=getint(),W=getint();
  vector<string> a(H);
  FOR(i,H){
    a[i]=getstr();
  }
  for(int i=1;i<H;i++){
    for(int j=0;j<W-1;j++){
      if(a[i][j]=='#'){
        for(int k=i-1;k>=0;k--){
          for(int l=j+1;l<W;l++){
            if(a[k][l]=='#'){
              cout<<"Impossible"<<endl;
              return 0;
            }
          }
        }
      }
    }
  }
  cout<<"Possible"<<endl;
  return 0;
}


Measured memory_bytes: 256