akhauriyash/Code-Regression huggingface dataset:
{-
  ?????¨?????? 30 ?????????????????? Data.Map ?????£??¨?????°????????£??????
-}
import Control.Monad
import Data.List
import qualified Data.Map as M

main :: IO ()
main = do
  d <- readLn
  when (d /= 0) $ do
    vs <- replicateM (d+3) readLn
    print $ head $ filter (outlier d $ M.fromList $ zip [0..] vs) [0..d+2]
    main
  
lerp :: M.Map Int Double -> Int -> Double
lerp vs x = sum $ zipWith (*) (map (\i -> mkCoef i (fromIntegral x) / mkCoef i (fromIntegral i)) $ M.keys vs) $ M.elems vs
  where
    mkCoef i y = product $ map ((y-) . fromIntegral) $ delete i $ M.keys vs

outlier :: Int -> M.Map Int Double -> Int -> Bool
outlier d vs e = all f $ delete e [0..d+2]
  where
    f i = abs (lerp xs i - vs M.! i) < 0.1
      where
        xs = M.delete i $ M.delete e vs

Measured memory_bytes: 4260
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int a[5], b[5], cnt[5];

int main(){
	for(int i = 1; i <= 3; i ++){
		scanf(" %d %d", &a[i], &b[i]);
		cnt[a[i]] ++;
		cnt[b[i]] ++;
	}
	int dis = 0, vis = 0;
	for(int i = 1; i <= 4; i ++){
		if(cnt[i] == 1) vis ++;
		if(cnt[i] == 2) dis ++;
	}
	if(dis == 2 && vis == 2) printf("YES\n");
	else printf("NO\n");
}

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

#define ll long long
#define ld long double

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << fixed << setprecision(6) << (ld) (n - n / 2) / n;
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

int ans = 0;
int n;
int win[10];
char mp[10][10];

void dfs(int a,int b){
	
	if(a == n-1 && b == n-1){
		ans++;
		return;
	}
	if(b == n){
		a++;
		b = 0;
	}
	
	if(a == b || mp[a][b] != '-'){
		dfs(a,b+1);
	}
	else{
		if(win[a] < (n-1) / 2){
			mp[a][b] = 'o';
			mp[b][a] = 'x';
			win[a]++;
			dfs(a,b+1);
			win[a]--;
			mp[a][b] = '-';
			mp[b][a] = '-';			
		}
		if(win[b] < (n-1) / 2){
			mp[a][b] = 'x';
			mp[b][a] = 'o';
			win[b]++;
			dfs(a,b+1);
			win[b]--;
			mp[a][b] = '-';
			mp[b][a] = '-';
		}
	}
}

void solve(){
	ans = 0;
	REP(i,10){
		win[i] = 0;
		REP(j,10){
			mp[i][j] = '-';
		}
	}
	int m;cin >> m;
	REP(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		mp[a][b] = 'o';
		mp[b][a] = 'x';
		win[a]++;
	}
	
	REP(i,n){
		if(win[i] > (n-1) / 2){
			cout << 0 << endl;
			return;
		}
	}
	
	dfs(0,0);
	
	cout << ans << endl;
}

int main(){
	
	while(cin >> n,n){
		solve();
	}
	
	return 0;
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll ar[10];

        for(ll i=1;i<=5;i++)
        cin>>ar[i];

        for(ll i=1;i<=5;i++)
        if(ar[i]==0)
        cout<<i;
    }
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String a = fs.next();
        String b = fs.next();
        String c = a + b;
        int n = Integer.parseInt(c);

        boolean flag = false;
        for (int i = 1; i <= 100100; ++i) {
            if (n % i == 0 && n / i == i) {
                flag = true;
                break;
            }
        }

        if (flag)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 37096
/*
Ashutosh Singh
Indian Institute of Information Technology Sri City
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n;
  cin >> n;
  int a[n];
  f(i,n)
    cin >> a[i];
  sort(a,a+n);
  int ans=0;
  f(i,n)
  {
      fp(j,i+1,n-1)
      {
          fp(k,j+1,n-1)
          {
              if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
                ans++;
          }
      }
  }
  cout << ans<< '\n';
  return;
} 

signed main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()-1) {
		if (s[i] != s[i + 1]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  cout << setprecision(10);
  int n;
  cin >> n;

  if (n == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  int a, b;
  cin >> a >> b;
  cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char X, Y;
  cin >> X >> Y;
  if(X<Y){
    cout << "<" << endl;
  }
  if(X>Y){
    cout << ">" << endl;
  }
  if(X==Y){
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
object Main extends App {
  //最大公約数
  def gcd(x: Int, y: Int): Int = {
    if(y == 0) x
    else gcd(y, (x % y))
  }
  //最小公倍数
  def lcm(x: Int, y: Int): Long = {
    if(x == 0 || y == 0) 0
    else (x.toLong * y.toLong) / gcd(x, y).toLong
  }

  val ab = scala.io.StdIn.readLine()
  val abArray = ab.split(" ").map(_.toInt).toVector
  println(lcm(abArray(0), abArray(1)))

}

Measured memory_bytes: 27332
#include <iostream>
#include <array>

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    long long int n;
    std::array<long long int, 7> arr;
    int age;

    while (std::cin >> n, n) {
        arr.fill(0);
        for (; n--;) {
            std::cin >> age;
            age = (age > 69 ? 60 : age);
            ++arr[age / 10];
        }
    
        for (const auto& cnt : arr) {
            std::cout << cnt << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1200
import math
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]
low = sum(H)//((N-1)*B+A)-1
high = max(H)//B+1
while high-low>1:
    mid = (high+low)//2
    cnt = 0
    for i in range(N):
        cnt += math.ceil(max(H[i]-mid*B,0)/(A-B))
    if cnt<=mid:
        high = mid
    else:
        low = mid
print(high)

Measured memory_bytes: 7068
#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 fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int N, D[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> D[i];

    set<int> se;
    rep(i, 0, N) se.insert(D[i]);
    int ans = se.size();
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
using namespace std;

#define maxn 3002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
const ll MOD = 1000000007;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int m, n;
ll f[maxn][maxn][2];

ll dp(int x, int i, int ok) {
    if (x==0) ok = 1;
    if (i==m+1) return ok;
    if (f[x][i][ok]>-1) return f[x][i][ok];
    f[x][i][ok] = 0;
    if (x>0) f[x][i][ok] = f[x][i][ok] + dp(x-1, i+1, ok) + dp(x, i+1, (ok || x==1) ? 1 : 0);
    if (n-x>0) f[x][i][ok] = f[x][i][ok] + dp(x, i+1, ok) + dp(x+1, i+1, ok);
    return f[x][i][ok]%=MOD;
}

int main() {
    //freopen("pilling.inp", "r", stdin);
    //freopen("", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d%d", &n, &m);
    ll res = 0;
    memset(f, -1, sizeof(f));
    FOR(i, 0, n)
        res = (res + dp(i, 1, 0))%MOD;
    printf("%I64d", res);
}



Measured memory_bytes: 141312
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    cout << (n+k-3)/(k-1)<< endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string s;
    cin >> s;

    ll p = 0;
    while(p < s.size()){
        cout << s[p];
        p += 2;
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3748
import java.io.*;
import java.util.*;
class Main {
    static int check;
    public static void main (String[] args) {
        //System.out.println("GfG!");
        int n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int W = sc.nextInt();
        int val[]=new int[n];
        int wt[]=new int[n];
        int valSum=0;
        for(int i=0;i<n;i++){
            wt[i]=sc.nextInt();
            val[i]=sc.nextInt();
            valSum+=val[i];
        }
        long K[][]=new long[n+1][valSum+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=valSum;j++)
                K[i][j]=0;
        }
        // Build table K[][] in bottom up manner
        int count=0;

        for (int i = 1; i <= n; i++)
        {
            int value = val[i-1];
            int weight=wt[i-1];
            //System.out.println(value+" "+weight);
            for (int j = 0; j <= valSum; j++)
            {       if(K[i-1][j]>0){
                int kval = value +j;
                long kwt = K[i-1][j]+weight;
                if(K[i][kval]==0){
                    K[i][kval]=kwt;
                }
                else{
                    K[i][kval]=Math.min(K[i][kval],kwt);
                }

            }
                    if(K[i-1][j]>0){
                        if(K[i][j]==0)
                            K[i][j]=K[i-1][j];
                        else{
                            K[i][j]=Math.min(K[i][j],K[i-1][j]);
                        }
                    }
                    if(j==value){
                        if(K[i-1][j]<=0)
                            K[i][j]=weight;
                        else{
                            K[i][j]=Math.min(weight,K[i-1][j]);
                        }
                    }

            }
        }
        // finding ans by taking max value of the array

        int ans=0;

            for(int j=1;j<=valSum;j++){

                if(K[n][j]<=W && K[n][j]!=0){
                    if(j>ans)
                        ans=j;
                }
            }



        System.out.println(ans);
        /*for(int i=1;i<=valSum;i++){
            System.out.println(i+":"+K[n][i]);
        }
        /*
        3 30
        4 50
        5 60*/
    }}

Measured memory_bytes: 125648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;cin >> n >> a >> b;
	int ans=0;
	rep(i,n){
		int t;cin >> t;
		if(t<a || t>=b) ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

bool check(int m, int i, int A[], int n) {

	if (m == 0) {
		return true;
	}

	if (i == n) {
		return false;
	}

	return check(m, i + 1, A, n) || check(m - A[i], i + 1, A, n);
}

int main() {

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

	int q;
	scanf("%d", &q);
	int Q[q];
	for (int i = 0; i < q; ++i) {
		int m;
		scanf("%d", &m);
		Q[i] = m;
	}

	for (int i = 0; i < q; ++i) {
		if (check(Q[i], 0, A, n)) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3208
N = int(input())
d = []

# inputをfor文でかく
for _ in range(N):
    d.append(input())

# ソートを行う
sortList = sorted(d, reverse=False)
count = 1

for i in range(N-1):
        #先の値と前の値の
        if sortList[i+1] > sortList[i]:
                count = count + 1
        else:
                continue


print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 200000;
int Tree[4* MAX];
void build(vector<int> &ar,int i , int l ,int r )
{
	if( l == r)
	{
		Tree[i] = l;
		return ; 
	}
	int mid = (l + r)/2;
	build(ar, i * 2 , l, mid);
	build(ar, i *2 + 1, mid + 1, r);
	Tree[i] = min(ar[Tree[i * 2]] , ar[Tree[i * 2 + 1]]) == ar[Tree[i * 2]] ? Tree[i * 2] : Tree[i * 2 +1];
}
int query(vector<int> &ar, int i, int l , int r , int tl ,int tr)
{
	if( tl > tr)
	{
		return -1;
	}
	if( tl == l && tr == r)
	{
		return Tree[i];
	}
	int mid = (l + r)/2;
	int left = query(ar, i * 2, l , mid, max(tl, l), min(tr, mid));
	int right = query(ar, i * 2 + 1, mid + 1, r, max(tl, mid + 1), min(tr, r));
	if(left != -1 && right != -1)
	{
		return min(ar[left], ar[right]) == ar[left] ? left : right;
	}
	return left != -1 ? left : right;
}
int solve(vector<int> &ar, int st, int end )
{
	if( st >= end)
		return 0;
	if( st == end - 1)
	{
		return ar[st];
	}
	int minn = query(ar, 1, 0, ar.size()-1, st, end -1);
	int res = ar[minn] * (minn - st + 1) * (end - minn );
	res += solve(ar, st, minn) + solve(ar, minn + 1, end);
	return res; 
}
int32_t main(){
	int n ;
	cin >> n ;
	vector<int> ar(n);
	for(int i =0 ; i<n ; i++)
	{
		cin >> ar[i];
	}
	build(ar, 1, 0, n-1);
	cout<< solve(ar, 0 , n)  <<endl;
}

Measured memory_bytes: 26624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		// ABC131-C
		static void Main(string[] args)
		{
			string str = Console.ReadLine();
			string[] vs = str.Split();

			long a = long.Parse(vs[0]), b = long.Parse(vs[1]), c = long.Parse(vs[2]), d = long.Parse(vs[3]);

			long countC = b / c - (a - 1) / c;
			long countD = b / d - (a - 1) / d;
			long lcm = LCM(c, d);
			long countCD = b / lcm - (a - 1) / lcm;

			long count = (b - a + 1) - countC - countD + countCD;

			Console.WriteLine(count);
		}

		public static long LCM(long m, long n)
		{
			if (m < n) {
				long tmp = m;
				m = n;
				n = tmp;
			}
			return m * n / GCD(m, n);
		}

		public static long GCD(long m, long n)
		{
			if (m < n) {
				long tmp = m;
				m = n;
				n = tmp;
			}
			if (n == 0) {
				return m;
			}
			return GCD(n, m % n);
		}
	}
}


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


int main() {
    ll k;
    cin >> k;
    ll cnt = 0;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    rrep(i, 9) {
        q.push(i);
    }
    set<ll> seen;
    while (++cnt < k) {
        ll n = q.top(); q.pop();
        if (seen.count(n) > 0) continue;
        else seen.insert(n);
        if (n % 10 != 0)
            q.push(n * 10 + (n % 10) - 1);
        q.push(n * 10 + (n % 10));
        if (n % 10 != 9)
            q.push(n * 10 + (n % 10) + 1);
    }
    cout << q.top() << endl;
    return 0;
}


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


int main() {

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

	if (a == b && b == c) cout << "No" << endl;
	else if (a != b && b != c && c != a)cout << "No" << endl;
	else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	int N; cin>>N;
	int ans=0;
	vector<int>a(N);
	rep(i,N){
		cin>>a[i];
		if(i%2==0){
			if(a[i]%2==1)ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	int n;
	scanf("%d",&n);
	int l[n<<1];
	for(int i=0;i<(n<<1);i++) scanf("%d",&l[i]);
	sort(l,l+(n<<1));
	int ans=0;
	for(int i=0;i<n;i++) ans+=l[i<<1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * 1_8_B
 * @author yosuke
 *
 */
public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	}

}

Measured memory_bytes: 24376
#include<stdio.h>
  
#define MAXLEN 10000
   
    
int main( void ) 
{
    int n,q;
    int S[MAXLEN+1],T[MAXLEN+1];
    int i,j;
    int cnt;    
      
    scanf( "%d", &n ); 
    for( i=0; i<n; i++ ) {
        scanf( "%d", &S[i] ); 
    }
  
    scanf( "%d", &q); 
    for( i=0; i<q; i++ ) {
        scanf( "%d", &T[i] ); 
    }
     
      
	for( i=0; i<q; i++ ) {
		for( j=i+1; j<q; j++ ) {
			if( T[i] == T[j] ) {
				T[j]=-1;
			}
		}
	}
    
	cnt=0;
	for( i=0; i<q; i++ ) {
		if( -1==T[i] ) { continue; }
		for( j=0; j<n; j++ ) {
			if( T[i] == S[j] ) {
				cnt++;
				break;
			}
		}
	}

    if( cnt ) {
        printf( "%d\n", cnt );
    } else {
        printf( "0\n" );
    }
  
    return 0;
}

Measured memory_bytes: 648
import java.util.*;

class Main{
	public static void main(String args[]){
		Solve s = new Solve();
		s.solve();
	}
}

class Solve{
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = in.nextInt();
			int b = in.nextInt();

			int l = 0, r = n - 1, s = 0;
			while(true){
				s++;
				int m = (l + r) / 2;
				if(m < 0 || m >= n) {
					break;
				}
				//System.out.println(l + " " + r);
				if(a[m] < b) l = m + 1;
				else if(a[m] > b) r = m - 1;
				else break;
				if(r < l) break;
			}

			System.out.println(s);
		}
	}
	
}

Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()

int main() {
    string s;
    cin >> s;
    int res = 0;
    stack<char> st;
    rep(i, s.size()) {
        if (st.empty() || st.top() == s[i])
            st.push(s[i]);
        else {
            res += 2;
            st.pop();
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
from operator import xor
from itertools import repeat

M, K = map(int, input().split())

if K >= 2 ** M:
    print(-1)
elif K == 0:
    print(*(i // 2 for i in range(2 ** (M + 1))))
else:
    if M == 1:
        print(-1)
    else:
        t = ([0] + list(reversed(range(1, 2 ** M))) + list(range(2 ** M)))
        print(*map(xor, t, repeat(K)))


Measured memory_bytes: 28616
n, k = map(int, input().split(" "))
list_k = list(map(int, input().split(" ")))
list_use_num = []
for i in range(10):
  if i not in list_k:
    list_use_num.append(i)
check_num = n
while True:
  list_check_num = list(map(int, str(check_num)))
  if set(list_check_num).issubset(list_use_num):
    print(check_num)
    break
  else:
    check_num += 1

Measured memory_bytes: 3060
from itertools import combinations
from collections import Counter

n = int(input())
xy_array = [[int(x) for x in input().split()] for y in range(n)]
comb_xy = combinations(xy_array, 2)
ans = float("INF")
res_x = 0
res_y = 0

vector = []
for i, j in comb_xy:
    xx = j[0] - i[0]
    yy = j[1] - i[1]
    vector.append((xx, yy))
    xx = i[0] - j[0]
    yy = i[1] - j[1]
    vector.append((xx, yy))

if n == 1:
    print(1)
    exit()
print(n - max(Counter(vector).values()))

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    string s;
    stack<int> polish;
    int a,b;
    while(cin>>s){
        if(s=="+"){
            a=polish.top();polish.pop();
            b=polish.top();polish.pop();
            polish.push(a+b);
        }
        else if(s=="-"){
            a=polish.top();polish.pop();
            b=polish.top();polish.pop();
            polish.push(b-a);
        }
        else if(s=="*"){
            a=polish.top();polish.pop();
            b=polish.top();polish.pop();
            polish.push(a*b);
        }
        else polish.push(stoi(s));
        if(getchar()=='\n'){
            cout<<polish.top()<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3156
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    int A[100010];
    rep(i, N) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, N) {
        int prev = ans;
        ans *= A[i];
        if(ans <= 0 || ans > INF2 || ans / A[i] != prev) {
            cout << "-1" << endl;
            return 0;
        }
    }
  	rep(i, N) {
		if(ans % A[i] != 0) {
			cout << "-1" << endl;
            return 0;
        }
    }
    if(ans > INF2) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  string ans[2*n];
  for(int i=0;i<n;i++){
    ans[2*i]=s[i];
    ans[2*i+1]=t[i];
  }
  for(int i=0;i<2*n;i++){
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int r, d, x;
	cin >> r >> d >> x;

	int tmp = r * x;
	for (int i = 0; i < 10; ++i) {
		cout << tmp - d << endl;
		tmp = r * (tmp - d);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,ans=0;
    cin >> n >> m;
    vector<vector<int>> sw(m);
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int d;
            cin >> d;
            d--;
            sw[i].push_back(d);
        }
    }
    int p[m];
    for(int i=0;i<m;i++) cin >> p[i];
    for(int i=0;i<(1<<n);i++){//スイッチを総当たり
        bitset<10> s(i);
        bool AllLight = 1;
        for(int j=0;j<m;j++){//電球の点灯判定
            int cnt = 0;//何個スイッチオンか
            for(auto k:sw[j]){
                if(s.test(k)) cnt++;
            }
            if(cnt%2!=p[j]) AllLight=0;
        }
        if(AllLight) ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3612
def solve(n, x):
    cnt = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                temp = i + j + k
                if temp > x:break
                elif temp == x:
                    cnt += 1
                    break
    
    return cnt

while True:
    n, x = map(int,input().split())
    if (n, x) == (0, 0):break
    print(solve(n, x))
    


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, 1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;
    vector<int> a = inp(n);

    int x = 0;

    rep(i, n) {
        x = x ^ a[i];
    }

    vector<int> ans(n);
    rep(i, n) {
        ans[i] = x ^ a[i];
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 4784
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, m; readV(n, m);
  writeln((n-1)*(m-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  ll sum = 0;
  ll mnum = 1e9;
  ll q_minus = 0;
  for(int i=0; i<N; i++) {
    ll a;
    cin >> a;
    if(a < 0) q_minus++;
    a = abs(a);
    sum += a;
    mnum = min(mnum, a);
  }
  ll ans = sum;
//  cout << mnum << endl;
  if(q_minus%2 == 1) ans -= 2*mnum;
  
  cout << ans << endl;
  return 0;
}

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

// 插入此處
const int MAXN = 1e5+2;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    LL A[MAXN];
    LL acc = 0;
    for (int i = 0; i <= N; ++i) {
        cin >> A[i];
        acc += A[i];
    }
    LL ans = 0, cur = 1;
    bool ok = true;
    bool need_check = true;
    for (int i = 0; i <= N; ++i) {
        if (need_check && cur < A[i]) {
            ok = false;
            break;
        }
        cur -= A[i];
        acc -= A[i];
        ans += A[i];
        ans += min(cur, acc);
        cur = min(cur, acc);
        cur *= 2;
        if (need_check && cur >= acc) {
            need_check = false;
        }
    }
    cout << (ok ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 4452
#include <cstdio>
#include <cmath>
using namespace std;

#define ll long long

ll pow(int n) {
	ll k = 1;
	for (int i = 0; i < n; i++) {
		k <<= 1;
	}
	return k;
}

int find(ll n) {
	int k = 0;
	while (pow(k++) <= n);
	return k - 1;
}

int main() {
    ll n, m;
	scanf("%lld %lld", &n, &m);
	printf("%d", find(m / n));
	return 0;
}

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

int main() {
  string A;
  cin>>A;
  vector<int>a(4);
  for(int i=0;i<4;i++){
    a.at(i)=A.at(i)-'0';
  }
  for(int i=0;i<8;i++){
    int sum =a.at(0);
    string s;
    s+=(char)('0'+a.at(0));
    for(int j=0;j<3;j++){
      if(i&(1<<j)){
        sum+=a.at(j+1);
        s+='+';
        s+=(char)('0'+a.at(j+1));
      }
      else{
        sum-=a.at(j+1);
        s+='-';
        s+=(char)('0'+a.at(j+1));
      }
    }
    if(sum==7){
      cout<<s<<"=7"<< endl;
      return 0;
    }
  }
}
    

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var an = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            long X = 0, x = 0, ans = long.MaxValue;
            X = an.Sum();
            for(var i=0;i<N-1;i++)
            {
                x += an[i];
                ans = Math.Min(ans, Math.Abs(X - 2 * x));
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 36548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
ll L, R;

int main() {
	scanf("%lld%lld", &L, &R);
	if(L == R) return puts("1"), 0;
	ll B = 1;
	while(B << 1 <= (L ^ R))
		B <<= 1;
	L &= B + B - 1;
	R &= B + B - 1;
	ll E = 1;
	while(E <= R - B)
		E <<= 1;
	printf("%lld\n", B - L + (E > L ? B : B - L + E));
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const double INFD = 1e100;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
vector<vector<int>> G(100005);
vector<int> dist;
void dfs(int V, int p=-1, int d=0){
  dist[V] = d;
  for(int nv: G[V]){
    if(nv == p){
      continue;
    }
    dfs(nv, V, d+1);
  }
}
vector<int> calc_dist(int N,int s){
  dist = vector<int> (N);
  dfs(s);
  return dist;
}
int main(){
  cin >> N;
  int u,v;
  cin >> u >> v;
  u--;
  v--;
  for(int i=0; i<N-1; i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  vector<int> dist_u(N);
  dist_u = calc_dist(N,u);
  vector<int> dist_v(N);
  dist_v = calc_dist(N,v);
  int ans=0;
  for(int i=0; i<N; i++){
    if(dist_u[i] < dist_v[i]){
      chmax(ans,dist_v[i]);
    }
  }
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 11120