akhauriyash/Code-Regression huggingface dataset:
l = input()
mod = 10**9 + 7

dp_less = [0 for i in range(0, len(l))]
dp_eq = [0 for i in range(0, len(l))]

dp_eq[0] = 2
dp_less[0] = 1

for i in range(1, len(l)):
    if l[i] == "0":
        dp_eq[i] = dp_eq[i - 1] % mod
        dp_less[i] = (3 * dp_less[i - 1]) % mod
    else:
        dp_eq[i] = (2 * dp_eq[i - 1]) % mod
        dp_less[i] = (3 * dp_less[i - 1] + dp_eq[i - 1]) % mod

print((dp_eq[-1] + dp_less[-1]) % mod)

Measured memory_bytes: 11040
#include<stdio.h>
int main(void) {
	char contest[201];
	char ans[1];

	int i;

	scanf("%[^\n\r]", contest);

	for (i = 1; contest[i-1] != ' '; i++) {
		
	}

	ans[0] = contest[i];
	printf("A%cC\n", ans[0]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[][] list = new int[3][n];

        for(int row = 0; row < 2; row++){
            for(int col = 0; col < n; col++){
                list[row][col] = scanner.nextInt();
            }
        }

        for(int col = 0; col < n; col++){
            list[2][col] = Math.abs(list[0][col] - list[1][col]);
        }

        // p = 1
        double sum = 0;
        for(int num : list[2]){
            sum += num;
        }
        System.out.println(sum);

        // p = 2
        sum = 0;
        for(int num : list[2]){
            sum += Math.pow(num, 2);
        }
        System.out.println(Math.sqrt(sum));

        // p = 3
        sum = 0;
        for(int num : list[2]){
            sum += Math.pow(num, 3);
        }
        System.out.println(Math.pow(sum, 1.0/3.0));

        // p = inf
        sum = list[2][0];
        for(int num : list[2]){
            sum = num > sum ? num : sum;
        }
        System.out.println(sum);

        scanner.close();
    }
}



Measured memory_bytes: 26384
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
p=0
for i in range(n):
  p+=b[a[i]-1]
  if i>=1 and a[i]-a[i-1]==1:
    p+=c[a[i-1]-1]
print(p)


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<mint> d  = {0, n - 1};
    vector<mint> d2 = {0, n - 1};
    for (int i = 2; i < n; ++i) {
        mint nxt = d[i - 1];
        if (i != 2)
            nxt += d2[i - 3];
        nxt += mint(n - 1) * (n - 1);
        d.push_back(nxt + (n - 1) + d[i]);
        d2.push_back(d2[i - 1] + d[i]);
    }
    mint ret = n;
    ret += d[n - 1] + mint(n - 1) * (n - 1);
    ret += d2[n - 3];
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 32844
function find(u,parent)
	if u==parent[u]
		u
	else
		parent[u]=find(parent[u],parent)
	end
end
function unite(u,v,parent,size)
	u=find(u,parent)
	v=find(v,parent)
	if u!=v
		if size[u]>size[v]
			parent[v]=u
			size[u]+=size[v]
		else
			parent[u]=v
			size[v]+=size[u]
		end
		true
	else
		false
	end
end
function main()
	N=parse(Int,readline())
	parent=collect(1:N)
	size=ones(Int,N)
	X=Pair{Int,Int}[]
	Y=Pair{Int,Int}[]
	id=1
	for s=readlines()
		x,y=map(x->parse(Int,x),split(s))
		push!(X,x=>id)
		push!(Y,y=>id)
		id+=1
	end
	G=Pair{Int,Pair{Int,Int}}[]
	sort!(X)
	sort!(Y)
	for i=1:N-1
		push!(G,abs(X[i].first-X[i+1].first)=>(X[i].second=>X[i+1].second))
		push!(G,abs(Y[i].first-Y[i+1].first)=>(Y[i].second=>Y[i+1].second))
	end
	sort!(G)
	ans=0
	for (c,(x,y))=G
		if unite(x,y,parent,size)
			ans+=c
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 168376
#include <bits/stdc++.h>
#define For(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
const int mod = 1000000000 + 7, MAXN = 200000 + 5;
int val[MAXN], lastF[MAXN];
int main(){
    int n;
    scanf("%d", &n);
    val[0] = 1;
    For(i, 1, n){
        int k;
        scanf("%d", &k);
        val[i] = val[i - 1];
        if (lastF[k] && lastF[k] + 1 != i) val[i] = (val[i] + val[lastF[k]]) % mod;
        lastF[k] = i;
    }
    printf("%d", val[n]);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int h,w;
string s[10];

int main(){
	cin >> h >> w;
	REP(i,0,h) cin >> s[i];
	
	int c=0;
	REP(i,0,h) REP(j,0,w) c+=(s[i][j]=='#');
	
	cout << (c==h+w-1?"Possible":"Impossible") << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque


def bfs(links, s, limit, bits):
    not_reachable = (1 << len(links)) - 1
    q = deque([(0, s, -1)])
    while q:
        cost, v, p = q.popleft()
        if cost > limit:
            break
        not_reachable ^= bits[v]
        cost += 1
        for u in links[v]:
            if u != p:
                q.append((cost, u, v))
    return not_reachable


def solve(n, k, ab):
    if k == 1:
        return n - 2

    links = [set() for _ in range(n)]
    for a, b in ab:
        a -= 1
        b -= 1
        links[a].add(b)
        links[b].add(a)

    limit = k // 2
    bits = [1 << i for i in range(n)]
    if k % 2 == 0:
        ans = min(bin(bfs(links, v, limit, bits)).count('1') for v in range(n))
    else:
        dists = [bfs(links, v, limit, bits) for v in range(n)]
        ans = min(bin(dists[a - 1] & dists[b - 1]).count('1') for a, b in ab)
    return ans


n, k = map(int, sys.stdin.buffer.readline().split())
ab = map(int, sys.stdin.buffer.read().split())
ab = list(zip(ab, ab))
print(solve(n, k, ab))


Measured memory_bytes: 5228
import java.io.*;
public class Main {
    public static void main(String[] args){
        //System.out.println("Input integer x (1 ≤ x ≤ 100) :");
        //1 ≤ x ≤ 100
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            if(x >= 1 && x <=100){
                System.out.println(x*x*x);
            } else{
                System.out.println("The integer x should be from 1 to 100.");
            }
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e ){
            System.out.println("The number format is incorrect");
        }
    }
}


Measured memory_bytes: 24208
// https://atcoder.jp/contests/abc122/tasks/abc122_c
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    string text;
    int n, q;
    cin >> n >> q;
    cin >> text;
    // Pre calculation array
    int dp_array[n];
    memset(dp_array, 0, sizeof(int));
    dp_array[0] = 0;
    for (int i = 1; i < n; i++)
    {
        if (text[i - 1] == 'A' && text[i] == 'C')
        {
            dp_array[i] = dp_array[i - 1] + 1;
        }
        else
        {
            dp_array[i] = dp_array[i - 1];
        }
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;

        cout << dp_array[r] - dp_array[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10**9)
def SCC(G):
  D=[]
  C=[len(G)-1]
  U=[1]*len(G)
  def DFS(x):
    if U[x]:
      U[x]=0
      for i in range(len(G[x])):
        DFS(G[x][i])
      D.append(x)
  
  for i in range(len(G)):
    if U[i]:
      DFS(i)
  GR=[[] for i in range(len(G))]
  for i in range(len(G)):
    for j in range(len(G[i])):
      GR[G[i][j]].append(i)
  R=[]
  U=[1]*len(G)
  def DFSR(x):
    if U[x]:
      R[-1].append(x)
      U[x]=0
      for i in range(len(GR[x])):
        DFSR(GR[x][i])
  
  for i in range(len(G)-1,-1,-1):
    if U[D[i]]:
      R.append([])
      DFSR(D[i])
  return R

S=sys.stdin.readlines()
N,M=map(int,S[0].split())
G=[[] for i in range(N)]
a,b=0,0
for i in range(M):
  a,b=map(int,S[i+1].split())
  G[a].append(b)
P=SCC(G)
print(len(P))
for i in range(len(P)):
  print(*([len(P[i])]+P[i]))


Measured memory_bytes: 652516
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#include<math.h>
#include <cmath>
#include <limits>
#include <cassert>
#include <algorithm>
#include <functional>
#define ll long long
#define M 1000000
#define pi 3.141592653
using namespace std;

int main() {
    ll N;
    cin >> N;
    ll mine = N;
    
    for(int i = 1; pow(i,2) <= N; i++){
        if(N % i == 0){
            mine = i + N / i;
        }
    }
    cout << min(N - 1, mine - 2) << endl;
}







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

using namespace std;
using ll = long long;
using ld = long double;

using Graph=vector<vector<int>>;
//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    Graph G(n);
    for(int i = 0; i < m; i++) {
        int ta,tb;
        cin >> ta >> tb;
        G[ta-1].emplace_back(tb-1);
        G[tb-1].emplace_back(ta-1);
    }

    vector<int> dir(n,-1);
    queue<int> que;
    dir[0]=0;
    que.push(0);
    while(!que.empty()) {
        int v= que.front();
        que.pop();

        for(int nv :G[v]) {
            if(dir[nv] != -1) continue;
            dir[nv] = v;
            que.push(nv);
        }
    }

    cout << "Yes" << "\n";
    for(int i = 1; i < n; i++) {
        cout << dir[i]+1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 10108
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, r; cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
    return 0;
}

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

int main(){
  int N;cin>>N;
  int P[N],Q[N];
  for(int i=0;i<N;i++) cin>>P[i];
  for(int i=0;i<N;i++) cin>>Q[i];
  int A[N],B[N];
  for(int i=1;i<=N;i++){
    A[i-1]=i;
    B[i-1]=i;
  }
  int a=0,b=0;
  do{
    bool flaga=true;
    for(int i=0;i<N;i++){
      if(A[i]!=P[i]){
        flaga=false;
        break;
      }
    }
    if(flaga) break;
    a++;
  }while(next_permutation(A,A+N));
    do{
    bool flagb=true;
    for(int i=0;i<N;i++){
      if(B[i]!=Q[i]){
        flagb=false;
        break;
      }
    }
    if(flagb) break;
    b++;
  }while(next_permutation(B,B+N));
  cout<<abs(a-b)<<endl;
  return 0;
}

Measured memory_bytes: 888
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
a=list(map(int,input().split()))
for i in range(n+1):
  if x-i not in a:
    print(x-i)
    exit()
  if x+i not in a:
    print(x+i)
    exit()

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

using namespace std;

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

typedef long long ll;

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

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;  cin >> n >> m;
    vector<int> city(60);
    rep(i, m) {
      int a, b;
      cin >> a >> b;
      city[a]++;
      city[b]++;
    }
    FOR(i, 1, n + 1) {
      cout << city[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]

# Create the pascal triangle
pascal = [[0 for i in range(j+1)] for j in range(2001)]
pascal[0][0] = 1
for i in range(2000):
    for j in range(i+1):
        pascal[i+1][j] += pascal[i][j]
        pascal[i+1][j+1] += pascal[i][j]


class Mod(object):
    def __init__(self, base):
        self.base = base
        self.x = 0

    def add(self, y):
        self.x += y % self.base
        self.x %= self.base

    def sub(self, y):
        self.x -= y % self.base
        self.x %= self.base

    def mul(self, y):
        self.x *= y % self.base
        self.x %= self.base


def comb(x, y):
    if x < y or (x == 0 and y != 0) or y < 0:
        return 0
    return pascal[x][y]


def f2(x, y):
    return comb(x+y-1, y-1)


def f(x, y):
    if x == 0 and y == 0:
        return 1
    return f2(x-y, y)


if __name__ == "__main__":
    BASE = int(1e+9 + 7)
    for i in range(1, k+1):
        count = Mod(BASE)
        count.add(f(k, i) * f(n-k, i-1))
        count.add(f(k, i) * f(n-k, i))
        count.add(f(k, i) * f(n-k, i))
        count.add(f(k, i) * f(n-k, i+1))
        print(count.x)


Measured memory_bytes: 341996
x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
x3, y3 = [int(i) for i in input().split()]

list = [x1,x2,x3,y1,y2,y3]

a=0
b=0
c=0
d=0

for i in list:
    if i == 1:
        a += 1
    if i == 2:
        b += 1
    if i == 3:
        c +=1
    if i == 4:
        d+=1

ans =0
list2 = [a,b,c,d]

for i in list2:
    if i % 2 == 1:
        ans += 1

if ans == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
n,k =input().split()
K = int(k)
N = int(n)

import math
P = 0
if N < K:
    for i in range(1,N+1):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
else:
    P += (N-K+1)/N 
    for i in range(1,K):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
print(P)

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

int main() {
	int N;
	cin >> N;
	int a = 0;
	for (int i = 0;i < N;i++) {
		string S;
		cin >> S;
		if (S == "Y") {
			a++;
		}
	}
		if (a > 0) {
			cout << "Four" << endl;
	}
		else {
			cout << "Three" << endl;
		}

	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int
#define N 100000
#define M 1000000007
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Sawlani
  *
  */

vector <pair <ll,ll> > v[N+1];
ll ans=0;
bool vis[N+1]={false};
ll dis=0;
ll color[N+1]={0};
 void dfs(ll i)
{
  f(j,0,v[i].size()-1)
  {
    ll p=v[i][j].first;
     if(!vis[p])
     {
         
         dis=dis+v[i][j].second;
        // cout <<  dis << endl;
         if(dis%2==0)
             color[p]=1;
        vis[p]=true;
        dfs(p);
        dis-=v[i][j].second;
      }
  }
     
     
     
}
ll a[N+1]={0};
  int main()
  {
      ll n;
      cin >> n;
     f(i,1,n-1)
    {
       ll x,y,w;
       cin >> x >> y >> w;
         v[x].pb({y,w});
         v[y].pb({x,w});
    }
     vis[1]=true;
     dfs(1);
     color[1]=1;
     f(i,1,n)
         cout << color[i] <<  endl;
}







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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;
const ll MOD = 1e9+7;

struct pl3{
	ll x, y, z;
	pl3(ll i){
		x = y = z = i;
	}
	pl3(ll _x, ll _y, ll _z){
		x = _x;
		y = _y;
		z = _z;
	}
};

vector<int> child[200005];
vector<pl3> dfs(int n){
	vector<pl3> ret;
	int mx = 0;
	for(auto t: child[n]){
		auto v = dfs(t);
		if(v.size() > ret.size()) swap(v, ret);
		int rn = ret.size() - v.size();
		rep(i,(int)v.size()){
			auto cur = ret[rn+i];
			ret[rn+i].x = (cur.x * v[i].x)%MOD;
			ret[rn+i].y = ( (cur.x * v[i].y)%MOD + (cur.y * v[i].x)%MOD )%MOD;
			ret[rn+i].z = ( (cur.y * v[i].y)%MOD
					+ (cur.z * v[i].x)%MOD + (cur.z * v[i].y)%MOD
					+ (cur.x * v[i].z)%MOD + (cur.y * v[i].z)%MOD + (cur.z * v[i].z)%MOD )%MOD;
		}
		chmax<int>(mx, v.size());
	}
	int rn = ret.size() - mx;
	rep(i,mx){
		auto &t = ret[rn + i];
		t.x = (t.x + t.z)%MOD;
		t.z = 0;
	}
	ret.emplace_back(1, 1, 0);
	return ret;
}


int main(){
	//ios_base::sync_with_stdio(false);
	int N;
	int p[200005];

	cin >> N;
	rep(i,N){
		cin >> p[i+1];
		child[p[i+1]].push_back(i+1);
	}

	auto ret = dfs(0);

	ll ans = 0, sum = 1;
	rep(i, (int)ret.size()){
		auto &t = ret[i];
		auto s = (t.x + t.y + t.z) % MOD;
		ans = (ans * s) % MOD;
		ans = (ans + (t.y * sum)%MOD) % MOD;
		sum = (sum * s) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 44656
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (1e9 + 7)
#define pb push_back
#define int long long 
using namespace std;
typedef pair<int,int> pii;

signed main(){
  int n,m;

  cin>>n>>m;

  vector<pii> ab;
  int a,b;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    ab.pb(pii(a,b));
  }
  sort(ab.begin(),ab.end());

  int res=0;
  for(int i=0;ab.size();i++){
    if(ab[i].second>=m){
      res+=m*ab[i].first;
      break;
    }
    res+=ab[i].second*ab[i].first;
    m-=ab[i].second;
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 2420
from __future__ import print_function
import time
from sys import stdin
from Queue import Queue
start = time.clock()
i = 0
num=int(stdin.readline())
L=[]
for _ in range(num):
    L.append([int(s) for s in stdin.readline().split()[2:]])
 
d=[-1]*num
d[0]=0
q=Queue(100)
q.put(0)
while not q.empty():
    u=q.get()
    for v in L[u]:
        if d[v-1]<0:
            d[v-1]=d[u]+1
            q.put(v-1)
for i,v in enumerate(d):
    print (i+1,v)

Measured memory_bytes: 6960
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	int K, S;
	cin >> K >> S;


	ll ans = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {

			if (S - (i + j) <= K && i+j <=S) {
				ans++;
			}

		}
	}

	cout << ans;






}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

for i in range(1000000007):
    if i % 2 == 0:
        C -= B
    else:
        A -= D
    #
    if A <= 0 or C <= 0: break

if i % 2 == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9104
#include <iostream>
#include <cmath>
#include <string>
#include <queue>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <string.h>
#include <stack>

using namespace std;
typedef long long ll;
const int mod=1000000007;
const int maxn=100007;

int main()
{
    int n,k;
    cin>>n>>k;
    char vis[1000];
    cin>>vis;
    vis[k-1]=vis[k-1]-'A'+'a';
    cout<<vis;
    return 0;
}


Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define int long long
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long

#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {
	int x;
	cin>>x;
	rep(i,1001)
	{
		rep(j,1001)
		{
			int ans1=i*i*i*i*i;
			int ans2=j*j*j*j*j;
			if(ans1+ans2==x){cout<<i<<" "<<-1*j;return;}
			else if(ans1-ans2==x){cout<<i<<" "<<j;return;}
			else if(ans2-ans1==x){cout<<j<<" "<<i;return;}
		}
	}
	
	

  }



signed main()
{
   FAST
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 3636
// You either die a hero, or you live long enough to see yourself become the villain.

/**
 *   author:  Blind_is_love
 *   created: 12.10.2019, 15:49
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

#define endl "\n"
#define vll vector<int>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
#define fi first
#define se second
#define mp make_pair
#define prime1 304933
#define prime2 15486277 
#define mod2 179424691
#define int ll

typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

const ll MOD = 1000000007;
const ll MAX = 1e5+100;
const double PI = 3.1415926;
const ll INF = 1e18;
const double EPS = 1e-5;

int n,W;
pii arr[101];
int dp[101][MAX];
bool seen[101][MAX];

int solve(int i, int rem) {

	if (rem < 0) return -1e18;
	if (i == -1) return 0;
	if (seen[i][rem]) return dp[i][rem];
	int f1 = solve(i-1, rem);
	int f2 = solve(i-1, rem-arr[i].fi);
	if (f2 >= 0) f2 += arr[i].se;
	seen[i][rem] = true;
	return dp[i][rem] = max(f1,f2);
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	clock_t t1, t2;
	t1 = clock();
	cin >> n >> W;
	
	for(int i = 0; i < n; ++i){
		cin >> arr[i].fi >> arr[i].se;
	}
	cout << solve(n-1,W) << endl;
	t2 = clock(); cerr << "time taken: " << (t2-t1)/(long double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 88320
import java.util.*;

class Main{

  static boolean check_rgb(int r,int g,int b){
    int rgb = r*100 + g*10 + b;
    return rgb % 4 == 0;
  }

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();

    if(check_rgb(r,g,b)){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 18900
import math
import itertools
import sys
n = int(input())
l = list(map(int, input().split()))


def isTriangle(a, b, c):
    if(a != b and b != c and c != a):
        if(a+b > c and b+c > a and c+a > b):
            return True
        else:
            return False
    else:
        return False


cnt = 0
for i in itertools.combinations(l, 3):
    if(isTriangle(i[0], i[1], i[2])):
        cnt += 1
print(cnt)


Measured memory_bytes: 67912
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main() {
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> c(h);
    int ans = 0;
    rep(i,h) cin >> c[i];
    rep(i0,1<<h) {
        rep(j0,1<<w) {
            int count=0;
            rep(i1,h) {
                rep(j1,w) {
                    if (i0 & 1<<i1) continue;
                    if (j0 & 1<<j1) continue;
                    if (c[i1][j1] == '#') count++;
                }
            }
            if (count == k) ans++;
        }
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int n, a[2][100];
	scanf("%d",&n);
	FOR(i,0,2) FOR(j,0,n) scanf("%d",&a[i][j]);
	int tmp, max = 0;
	FOR(i,0,n) {
		tmp = 0;
		FOR(j,0,i+1) tmp += a[0][j];
		FOR(j,i,n) tmp += a[1][j];
		if(max < tmp) max = tmp;
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cap = sc.nextInt();
		long dp[] = new long[cap+1];
		for(int item = 0; item < n; item++) {
			int w = sc.nextInt();
			long v = sc.nextLong();
			for(int i = cap; i != 0 ; i--) {
				if(i >= w)dp[i] = Math.max(dp[i],  v + dp[i-w]);
			}
//			System.out.println(Arrays.toString(dp));
		}
		System.out.println(dp[cap]);
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  cin  >> s >> t;
  int a,b; cin >> a >> b;
  string u; cin >> u;
  if(s == u){
    cout << a-1 << " " << b << "\n";
  }else{
    cout << a << " " << b-1 <<  "\n";
  }
}

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

a.sort()
s=sum(a)
ans=[]
ans.append(s)
N=n//2

for i in range(1,N+1):
  x=i*2-1
  y=i*2
  s+=a[x-1]*-2
  s+=a[y-1]*-2
  ans.append(s)
  
print(max(ans))


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

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

ll eggdrops[51][51];

int main(){
  // https://oeis.org/A180975
  REP(i,51)REP(j,51){
    if(i==0||j==0)eggdrops[i][j]=0;
    else eggdrops[i][j]=eggdrops[i-1][j-1]+1+eggdrops[i-1][j];
  }

  int T;
  cin >> T;
  REP(_t,T){
    ll N,E;
    cin >> N >> E;
    REP(n,51){
      ll w = eggdrops[n][E];
      if(N<=w){
        cout << n << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;

bool C(string s){
    string t;
    t = s;
    reverse(t.begin(), t.end());
    if(s == t){
        return true;
    }
    return false;
}

int main(){

    string s, t, u;

    cin >> s;
    t = s;
    u = s;

    int n = s.size();

    t.erase((n-1) / 2);
    u.erase(0, (n+3)/2 - 1);
    if( C(s) && C(t) && C(u) ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main(){
    string s;
    string t;
    cin>>s>>t;
    bool isok=false;
    for(int i=0;i<s.size();i++){
        string sr=s.substr(i,s.size()-i)+s.substr(0,i);
        isok|=sr==t;
    }
    cout<<(isok ? "Yes" : "No")<<endl;

}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int D;
    std::cin >> D;

    if (D == 25)
    {
        std::cout << "Christmas" << std::endl;
    }
    else if (D == 24)
    {
        std::cout << "Christmas Eve" << std::endl;
    }
    else if (D == 23)
    {
        std::cout << "Christmas Eve Eve" << std::endl;
    }
    else if (D == 22)
    {
        std::cout << "Christmas Eve Eve Eve" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<climits>
#include<algorithm>
using namespace std;
int main()
{
	int time[101][101],cost[101][101],n,m,i,j,k,a,b,c,d;
	while(scanf("%d%d",&n,&m),m)
	{
		for(i=0;i<101;++i)
		{
			for(j=0;j<101;++j)
			{
				time[i][j]=cost[i][j]=INT_MAX/2;
			}
		}
		for(i=0;i<n;++i)
		{
			scanf("%d%d%d%d",&a,&b,&c,&d),cost[a][b]=cost[b][a]=c,time[a][b]=time[b][a]=d;
		}
		for(k=1;k<=m;++k)
		{
			for(i=1;i<=m;++i)
			{
				for(j=1;j<=m;++j)
				{
					time[i][j]=min(time[i][j],time[i][k]+time[k][j]),
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
				}
			}
		}
		scanf("%d",&k);
		for(i=0;i<k;++i)
		{
			scanf("%d%d%d",&a,&b,&c);
			printf("%d\n",c?time[a][b]:cost[a][b]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret.sorted()
}

func main() {
    let input = readInts()
    let (N, X, T) = (input[0], input[1], input[2])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    var cnt = 1
    
    while N > X * cnt {
        cnt += 1
    }
    print(T * cnt)
}
main()


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

string s, t, res;
int dp[3005][3005];

int solve(int a, int b){
    if(a >= s.size() || b >= t.size()) return dp[a][b] = 0;
    if(dp[a][b] != -1) return dp[a][b];
    int r1 = solve(a+1, b);
    int r2 = solve(a, b+1);
    int r3 = s[a] == t[b] ? solve(a+1, b+1)+1 : 0;
    return dp[a][b] = max(r1, max(r2,r3));
}

void rebuild(int a, int b){
    if(a >= s.size() || b >= t.size()) return;
    int r1 = dp[a+1][b];
    int r2 = dp[a][b+1];
    // int r3 = s[a] == t[b] ? dp[a+1][b+1] + 1 : 0;
    if(dp[a][b] == r1) rebuild(a+1, b);
    else if(dp[a][b] == r2) rebuild(a, b+1);
    else res += s[a], rebuild(a+1, b+1);
}

int main(){
    memset(dp, -1, sizeof dp);
    cin >> s >> t;
    if(solve(0,0) == 0){
        string weiss = "";
        cout << weiss << endl;
        return 0;
    }
    rebuild(0,0);
    cout << res << endl;
	return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

char a[1010][1010];
int dp[1010][1010];

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) cin >> a[i][j];
	}
	
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i > 0 && a[i - 1][j] != '#') 
				dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			if (j > 0 && a[i][j - 1] != '#')
				dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
		}
	} 
	
	cout << dp[h - 1][w - 1] << '\n';
}



Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

constexpr int tmax = 100000;

int main() {
    int N, C; cin >> N >> C;
    vector<vint> ch(C, vint(tmax+5, 0));
    rep(i, N) {
        int s, t, c; cin >> s >> t >> c; c--;
        ch[c][s-1] += 1;
        ch[c][t] -= 1;
    }
    rep(c, C) rep(t, tmax) {
        ch[c][t+1] += ch[c][t];
    }
    rep(c, C) rep(t, tmax) {
        if(ch[c][t] > 1) ch[c][t] = 1;
    }
    vint imos(tmax);
    rep(t, tmax) {
        rep(c, C) {
            imos[t] += ch[c][t];
        }
    }
    int maxim = 1;
    rep(t, tmax) {
        chmax(maxim, imos[t]);
        // cerr << imos[t] << " ";
    }
    // cerr << endl;
    cout << maxim << endl;
    return 0;
}


Measured memory_bytes: 12536
<?php
    for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
    {
        $input = explode(" ", trim(fgets(STDIN)));
        if( 0 == $input[0] &&
            0 == $input[1]
        )
        {
            break;
        }
         
        $r = str_split($input[0]);
        $a = str_split($input[1]);
         
        $hit = 0;
        $brow = 0;
        $loop_r = 0;
        foreach( $r as $r_char )
        {
            $loop_a = 0;
            foreach($a as $a_char)
            {
                if($r_char == $a_char)
                {
                    if($loop_r == $loop_a)
                    {
                        $hit++;
                    }
                    else
                    {
                        $brow++;
                    }
                    break;
                }
                $loop_a++;
            }
            $loop_r++;
        }
        echo $hit . " " . $brow . "\n";
    }
?>


Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(n / i != i) ret.push_back(n/i);
        }
    }
    return ret;
}

inline ll p(ll a){
    return a*a*a*a*a;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll x;cin>>x;
    

    for(ll a=1;p(a)-p(a-1)<=x;a++){
        for(ll b=0;b<a;b++){
            if(p(a)-p(b)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }

    for(ll a=1;p(a)<=x;a++){
        for(ll b=0;p(a)+p(b)<=x;b++){
            if(p(a)+p(b)==x){
                cout<<a<<" "<<-b<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(20)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};	
void solve(){
	ll n;
	cin>>n;
	vl vec(n);
	cin>>vec;
	ll me=0;
	for(ll x:vec) me^=x;
	vl ans(n);
	
	for(int i=0;i<n;i++) ans[i]=me^vec[i];
	cout<<ans;
		
			

		
	
	
	
	
	
	
	
	
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 6332
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W; 
  cin >> H >> W;

  vector<vector<int>> A(H, vector<int>(W));
  REP(i, H) REP(j, W) cin >> A[i][j];

  vector<vector<int>> B(H, vector<int>(W));
  REP(i, H) REP(j, W) cin >> B[i][j];

  bool dp[H+1][W+1][40000];
  memset(dp, false, sizeof(dp));
  dp[0][0][20000] = true;
  
  REP(i, H) REP(j, W) REP(k, 40000){
    if(!dp[i][j][k]) continue;
    dp[i+1][j][k+A[i][j]-B[i][j]] = true;
    dp[i+1][j][k-A[i][j]+B[i][j]] = true;
    dp[i][j+1][k+A[i][j]-B[i][j]] = true;
    dp[i][j+1][k-A[i][j]+B[i][j]] = true;
  }

  int ans = INF;
  REP(k, 40000){
    if(dp[H-1][W][k]) chmin(ans, abs(20000-k));
    if(dp[H][W-1][k]) chmin(ans, abs(20000-k));
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256768
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,A,B,stack[N];
char c[N];
int main()
{
	scanf("%d%d",&A,&B);
	if (A<=B)
	{
			puts("Impossible");
			fflush(stdout);
	}
	else 
	{
			for (i=0;i<A+B;++i)
				if (!stack[0])
					stack[++stack[0]]=i;
				else 
				{
					 printf("? %d %d\n",i,stack[stack[0]]);
					 fflush(stdout);
					 scanf("%s",&c);
					 if (c[0]=='Y') stack[++stack[0]]=i;
					 else --stack[0];
				}
	int now=stack[1];
	string s; s+='!';
	for (i=0;i<A+B;++i)
	{
		  printf("? %d %d\n",now,i);
		  fflush(stdout);
		  scanf("%s",c);
		  if (c[0]=='Y') s+='1';
		  else s+='0';
	}
	cout<<s<<endl;
	}
}


Measured memory_bytes: 848