akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define fr(i,a,b) for(int i=a;i<=b;i++)


const int N=2e5+5;

void solve()
{
	int n;
	cin>>n;
	map<int,int> mp;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		sum+=x;
		mp[x]++;
	}
	int q;
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		sum-=(b*mp[b]);
		sum+=(c*mp[b]);
		mp[c]+=mp[b];
		mp[b]=0;
		cout<<sum<<endl;
	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	IOS;

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

}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
std::vector<int> a[1000];
int ans;
int bj[1005];
void dfs(int k,int n,int c){
	if(c==n){
		ans++;
		return;
	}
	for(int i=0;i<a[k].size();i++){
		if(!bj[a[k][i]]){
			bj[a[k][i]]=1;
			dfs(a[k][i],n,c+1);
			bj[a[k][i]]=0;
		}
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		a[u].push_back(v);
		a[v].push_back(u);
	}
	memset(bj,0,sizeof(bj));
	ans=0;
	bj[1]=1;
	dfs(1,n,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n, k, x, i, C, sum=0, l=0;
    cin >> n >> k;
    vector<int>v;
    while(n--){
        cin >> x;
        sum += x;
        v.push_back(x);
    }
    C = sum / (4*k);
    for(i=0; i<v.size(); i++){
        if(v[i]>=C)l++;
        if(l==k)break;
    }
    l==k ? cout << "Yes" : cout << "No";
    return 0;
}


Measured memory_bytes: 256
def main():
    H, N = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    dp = [float("inf")] * (H+1)
    dp[0] = 0
    for i in range(N):
        for j in range(H+1):
            dp[j] = min(dp[j], dp[max(j-A[i], 0)] + B[i])
    print(dp[H])


if __name__ == "__main__":
    main()


Measured memory_bytes: 44636
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int a, b; cin >> a >> b;
    int ans;
    ans = a-2*b;
    cout << (ans>0 ? ans : 0) << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >>n >>m;
  if (n%2!=0){
  	for (int i=1;i<=m;i++){
    	cout << i <<" " << n+1-i << endl;
 	 }
  }
  else{
    for (int i=1;i<=min(m,n/4);i++){
    	cout << i <<" " << n+1-i << endl;
 	 }
    for (int i=n/4+1;i<=min(m,n);i++){
    	cout << i <<" " << n-i << endl;
 	 }
  }
}


Measured memory_bytes: 3608
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (auto &i : a) {
    cin >> i;
    x -= i;
  }
  sort(all(a));
  int ans = n;
  while (x >= a[0]) {
    x -= a[0];
    ans++;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int x, y; cin >> x >> y;
    int a = 4 * x - y, b = y - 2 * x;
    if (a >= 0 && a % 2 == 0 && b >= 0 && b % 2 == 0 && (a != 0 || b != 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		int ans = 1;
		char now = s[0];
		for (int i = 1; i < n; i++) {
			if (s[i] != now) {
				ans++;
			}
			now = s[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26512
h,w = map(int,input().split())
s = [input() for _ in range(h)]
res = []
for i in s:
    res.append(list(i))

def inside(x, y):
    return 0 <= x < h and 0 <= y < w

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        cnt = 0
        for dx in [-1,0,1]:
            for dy in [-1,0,1]:
                if dx == 0 and dy == 0:
                    continue
                x, y = i + dx, j + dy
                if not inside(x, y):
                    continue
                if s[x][y] == '#':
                    cnt += 1
        res[i][j] = str(cnt)

for l in res:
    print(*l, sep = '')

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    ll ans = 1;
    cin >> n;
    vector<int> v1(n), v2(n), v3(n, 0);
    for (auto &&i : v1) scanf("%d", &i);
    for (auto &&i : v2) scanf("%d", &i);
    if(v1[n-1] != v2[0]){
        cout << 0 << "\n";
        return 0;
    }
    for (int i = 1; i < n-1; ++i) {
        if(v1[i] == v1[i-1] && v2[i] == v2[i+1]) (ans *= min(v1[i], v2[i])) %= MOD;
        else if(v1[i] > v1[i-1] && v2[i] == v2[i+1] && v2[i] < v1[i]) ans = 0;
        else if(v1[i] == v1[i-1] && v2[i] > v2[i+1] && v2[i] > v1[i]) ans = 0;
        else if(v1[i] > v1[i-1] && v2[i] > v2[i+1] && v2[i] != v1[i]) ans = 0;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
l = inputILL(N)

count = 0
S = 0
for i in range(N):
  for j in range(i+1,N):
    a,b = l[i]
    c,d = l[j]
    S += math.sqrt((a-c)*(a-c)+(b-d)*(b-d))
    count += 1
    
print(S/count*(N-1))

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


int main (){
    long long S;
    cin>>S;
    int Keta=0;
    long long SS=S;
    while(SS>0){
        SS/=10;
        Keta ++;
    }
   //cout<<Keta<<endl;
    vector<int> Num(Keta);
    long long Totyu=0;
    for(int i=0; i<Keta; i++){
        int A=pow(10, i);
      	//cout<<A<<endl;
        int X =((S-Totyu)/A)%10;
        Num.at(Keta-i-1)=X;
      	//cout<<X<<endl;
        Totyu += X*A/10;
        //cout<<S-Totyu<<endl;
    }
  	
  	/*for(int i=0; i<Keta; i++){
      cout<<Num.at(i);
    }
  	cout<<endl;*/
    
    int MinDif=999;
    for(int i=0; i<Keta-2; i++){
        int Dif=abs(753 - Num.at(i)*100-Num.at(i+1)*10-Num.at(i+2));
        MinDif=min(Dif, MinDif);
      	//cout<<Dif<<endl;
    }
    cout<<MinDif<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

using node_t = int;

struct connection_t {
  int64_t length;
  int to;
};

static int n;
static std::vector<node_t> nodes;
static std::vector<std::vector<connection_t>> connections;

void sub_solve(int idx, int color) {
  if (nodes[idx] >= 0) {
    return;
  }

  nodes[idx] = color;
  for (const auto& connection : connections[idx]) {
    sub_solve(connection.to, (color + connection.length) % 2);
  }
}

void solve() { sub_solve(0, 0); }

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n;
  nodes.resize(n, -1);
  connections.resize(n, std::vector<connection_t>());
  for (int i = 0; i < n - 1; i++) {
    int from;
    int to;
    int64_t length;
    std::cin >> from >> to >> length;
    from--;
    to--;
    connection_t connection;
    connection.to = to;
    connection.length = length;
    connections[from].push_back(connection);
    connection.to = from;
    connections[to].push_back(connection);
  }
  solve();
  for (auto color : nodes) {
    std::cout << color << std::endl;
  }
  return 0;
}


Measured memory_bytes: 8832
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
const int N = (int) 105, mod = (int) (1 << 23) * 17 * 7 + 1;
typedef pair<int, bitset<N>> num;
int compute_g(num);
struct cmp {
	bool operator() (num a, num b) const {
		if (a.first != b.first) return a.first < b.first;
		for (int j = 0; j < (int) a.first; ++j)
			if (a.second[j] != b.second[j]) {
				return a.second[j] < b.second[j];
			}
		return 0;
	}
};
map<num, int, cmp> fdp, gdp;
void sadd(int &x, int y) {
	x += y;
	while (x >= mod) x -= mod;
}
int compute_f(num x) {
	if (x.first == 1) return 1 + x.second[0];
	if (fdp.find(x) != fdp.end()) return fdp[x];
	int &res = fdp[x];
	int g = 1;
	int n = x.first;
	for (int j = 0; j < n; ++j) g = g * (1 + x.second[j]) % mod;
//	sadd(res, g);
	for (int j = 1; j < n; ++j) {
		num xl, xr;
		xl.first = j;
		xr.first = n - j;
		for (int i = 0; i < j; ++i) xl.second[i] = x.second[i];
		for (int i = j; i < n; ++i) xr.second[i - j] = x.second[i];
		sadd(res, compute_f(xr) * (LL) compute_g(xl) % mod);
	}
	sadd(res, compute_g(x));
	return res;
}
int compute_g(num x) {
	if (x.first == 1) return 1 + x.second[0];
	if (gdp.find(x) != gdp.end()) return gdp[x];
	int &res = gdp[x];
	int n = x.first;
	for (int k = 2; k <= n; ++k) if (n % k == 0) {
		num nxt;
		nxt.first = n / k;
		for (int j = 0; j < n / k; ++j) {
			nxt.second[j] = 1;
			for (int i = j; i < n; i += nxt.first)
				nxt.second[j] = nxt.second[j] & x.second[i];
		}	
		sadd(res, compute_f(nxt));
	}
	return res;
}
int main() {
	string s;
	cin >> s;
	num fs;
	fs.first = (int) s.size();
	for (int j = 0; j < (int) s.size(); ++j) 
		fs.second[j] = s[j] - '0';
	cout << compute_f(fs) << '\n';;
}



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

const ll MAX = 300000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  // 前処理
  COMinit();
  
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  // 空き部屋数でループ
  for(ll i=0; i<min(n,k+1) ; ++i) {
    ll b = COM(n,i) % MOD;
    b = b * COM(n-1, i) % MOD;
    ans = (ans + b)  % MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<complex>
#include<string>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> ivv;

vector<string> v;

int main()
{
	int n,m;
	bool flag = true;
	
	cin >> n;
	
	REP(i,n)
	{
		string tmps;
		cin >> tmps;
		v.PB(tmps);
	}
	
	cin >> m;
	
	REP(i,m)
	{
		bool con = false;
		string tmp;
		cin >> tmp;
		
		REP(j,n)
		{
			if(v[j] == tmp)
			{
				if(flag)
				{
					cout << "Opened by " << tmp << endl;
					flag = !flag;
					con = true;
					break;
				}
				else
				{
					cout << "Closed by " << tmp << endl;
					flag = !flag;
					con = true;
					break;
				}
			}
		}
		
		if(!con)
			cout << "Unknown " << tmp << endl;
		
	}
			
	
	return 0;
}

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

int main(){
    string a,b,c;
    cin >> a >> b;
    c = a + b;
    int x = stoi(c);
    for(int i = 1; i < 100101; i++){
        if(x == i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '1') n[i] = '9';
    else n[i] = '1';
  }
  cout << n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int hs[100][100];
int main(){
  int n;
  double r;
  while(cin>>r>>n,r+n){
    memset(hs,0,sizeof(hs));
    for(int i=0;i<n;i++){
      int x1,x2,h;
      cin>>x1>>x2>>h;
      x1+=20;
      x2+=20;
      for(int i=x1;i<x2;i++){
	for(int j=0;j<=h;j++)
	  hs[i][j]=1;
      }
    }
    auto check = [&](double t){
      for(int i=0;i<r;i++){
	double x=i;
	int y=sqrt(r*r-x*x)+t+1-r;
	//cout<<i<<" "<<t<<" "<<y<<endl;
	if(y<=0)continue;
	if(!hs[i+20][y])return false;
	if(!hs[-i+20-1][y])return false;
      }
      return true;
    };
    double ub=100,lb=0,mid;
    for(int i=0;i<200;i++){
      mid=(ub+lb)/2;
      if(check(mid))lb=mid;
      else ub=mid;
    }
    cout<<fixed<<setprecision(12)<<lb<<endl;
  }
  return 0;
}



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

int main()
{
    int n;
    int a[100005];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int ans=0,t;
    for(int i=1;i<=n;i++)
    {
        if(i==a[i])
        {
            t=a[i];
            a[i]=a[i+1];
            a[i+1]=t;
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  string a,b,c;
  cin>>a;
  fo(i,a.size()){
    if(i<4)
      b.push_back(a[i]);
    else
      c.push_back(a[i]);
  }
  cout<<b<<' '<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,co,ans;
bool fl;
struct edge{int to,cost;};
ll ren,sousa;
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k>>s;
    rep(i,n)ans+="z";
    co=s;
    reverse(all(co));
    s+=co;
    k--;
    sort(all(co));
    rrrep(i,Size(s)-1,n-1){
        rrrep(j,i,i-n+1){
            if(s[j]!=co[0])break;
            cnt++;
        }
        ren=max(ren,cnt);
        cnt=0;
    }
    while(1){
        if(ren>=n)break;
        sousa++;
        ren*=2;
    }
    if(sousa<=k){
        rep(i,n){
            cout<<co[0];
        }
        cout<<"\n";
        return 0;
    }
    else{
        while(1){
            //cout<<s<<" "<<k<<"\n";
            if(k==0){
                rep(i,n+1){
                    string now="";
                    rrep(j,i,i+n){
                        now+=s[j];
                    }
                    if(ans>now)ans=now;
                }
                break;
            }
            //いいやつ取り出す
            string anss="";
            rep(i,n)anss+="z";
            rrrep(i,Size(s)-1,n-1){
                string now="";
                rrrep(j,i,i-n+1){
                    now+=s[j];
                }
                if(anss>now)anss=now;
            }
            k--;
            //sを二倍のやつにする
            string hozon=anss;
            reverse(all(hozon));
            s=hozon+anss;
        }
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 384
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#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 ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
#define int ll 
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
long const M=1e9+7;
const long mxN =1e5+2 ;
const ll INF =1e18;
void solve(){ 
  int n  ;
  cin >> n ;
  vi v(n) ;
  int x=0 ;
  For(i,n){
    cin >> v[i] ;
    x^=v[i] ;
  }
  For(i,n){
    cout << (x^v[i]) <<" " ;
  }
  
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}
	

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<ctime>
using namespace std;
#define ll long long
#define IO std::ios::sync_with_stdio(false);std::cin.tie(0)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
#define fi first
#define se second
#define pb push_back

const int maxn = 101;

struct node {
	ll pos, ns, nt;
	bool operator<(const node &T)const{
		return  (nt > T.nt || (nt == T.nt && ns < T.ns));
	}
};

struct Edge {
	ll to, nxt, w, t;
}edge[maxn << 1];

ll n, m, s, head[maxn], mm, c[maxn], d[maxn];
ll dp[100][2600];

void add(int x, int y, int w, int t) {
	edge[++mm] = { y,head[x],w,t };
	head[x] = mm;
}

int main() {
	std::ios::sync_with_stdio(false); std::cin.tie(0);
	cin >> n >> m >> s;
	rep(i, 1, m) {
		int x, y, w, t;
		cin >> x >> y >> w >> t;
		add(x, y, w, t);
		add(y, x, w, t);
	}
	rep(i, 1, n) cin >> c[i] >> d[i];
	if (s > 2500) s = 2500;
	mset(dp, 0x7f);
	dp[1][s] = 0;
	priority_queue<node>q;
	q.push({ 1,s,0 });
	while (!q.empty()) {
		node now = q.top();
		q.pop();
		ll x = now.pos;
		ll nt = now.nt;
		ll ns = now.ns;
		if (nt !=dp[x][ns]) continue;
		int i = 1;
		for (; ns + i * c[x] < 2500; i++) {
			ll t = i * d[x] + nt;
			ll s1 = ns + i * c[x];
			if (dp[x][s1] > t) {
				dp[x][s1] = t;
				q.push({ x,s1,t });
			}
		}
		if (dp[x][2500] > i * d[x] + nt) {
			q.push({ x,2500,i * d[x] + nt });
			dp[x][2500] = i * d[x] + nt;
		}
		for (i = head[x]; i; i = edge[i].nxt) {
			ll to = edge[i].to;
			ll w = edge[i].w;
			ll t = edge[i].t;
			if (ns >= w && dp[to][ns-w] > nt + t) {
				q.push({ to,ns - w,nt + t });
				dp[to][ns-w] = nt + t;
			}
		}
	}
	rep(i, 2, n) {
		ll ans = 0x7f7f7f7f7f7f7f;
		rep(j, 0, 2500) {
			ans = min(ans, dp[i][j]);
		}
	 cout << ans << '\n';
	}
}



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

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;

#ifdef LOCAL
  #define debug_echo(e) cin << "L" << __LINE__ << ": " << e
  #define debug_repr(e) cin << "L" << __LINE__ << ": " << #e << " = " << e
#else
  #define debug_echo(e)
  #define debug_repr(e)
#endif

int main() {
  int A, B, C; cin >> A >> B >> C;
  if (A == B) {
    cout << C;
  } else if (A == C) {
    cout << B;
  } else {
    cout << A;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        String acgt = "ACGT";
        int ans = 0;
        for(int i = 0; i < S.length; i++) {
            int c = 0;
            for(int j = i; j < S.length; j++) {
                if(acgt.indexOf(S[j]) == -1) break;
                c++;
            }
            ans = Math.max(ans, c);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
lis=[LI() for i in range(n)]
lis.sort()
pay=0
i=0
while m>0:
    pay+=lis[i][0]*min(m,lis[i][1])
    m-=min(m,lis[i][1])
    i+=1
print(pay)
    
    
    
    

    


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 505;

int N;

void solve() {
    FOR (a, 1, N+1) FOR (b, a+1, N+1) {
        int c = (a^b);
        int k = 1;
        while(c%2 == 0) {
            k++;
            c >>= 1;
        }
        cout << k << ((b == N) ? "\n" : " ");
    }
}

int main() {
    cin >> N;
    solve();
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 1010;
typedef long long ll;
char s[N], t[N];
int n, m;
int main() {
	
	scanf("%s %s", s + 1, t + 1);
	n = strlen(s + 1), m = strlen(t + 1);
	
	int ans = 0x3f3f3f3f;
	for(int i = 1; i <= n-m+1; i++) {
		int tmp = 0;
		for(int j = 1; j <= m; j++) {
			if(s[i+j-1] != t[j]) tmp++;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

const int N = 200010;
int mod[N];
int DP[2020];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s;
	cin >> s;
	int n = s.size();
	M00(i, N) {
		if (i == 0) mod[0] = 1;
		else mod[i] = (mod[i-1] * 10) % 2019;
	}
	ll ans = 0;
	int sum = 0;
	DP[0] = 1;
	M00(i, n) {
		sum += (s[n-i-1] - '0') * mod[i];
		sum %= 2019;
		ans += DP[sum];
		DP[sum]++;
	}
	cout << ans << endl;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 101;

int x[maxn];

map<string,int>mapa;

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ma = 0;
  for(int i = 0; i < n ; i++)
  {
    string s;
    cin >> s;
    mapa[s]++;
    ma = max(ma, mapa[s]);
  }

  for(const auto &m : mapa)
  {
    if(m.second == ma)
    {
      cout << m.first << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 23808
//file_name:ABC59_B.cpp
#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("GREATER");}else{puts("LESS");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string a,b;
    cin >> a >> b;

    if(a.size()==b.size()){
        rep(i,a.size()){
            if(a[i]>b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
            if(b[i]>a[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
        return 0;
    }
    if(a.size()>b.size())yn;
 
    return 0;
}



Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input())
cost = 0

q_ef = q*8
h_ef = h*4
s_ef = s*2

if min(q_ef, h_ef, s_ef, d) == d:
    cost += d * (n//2)
    n %= 2

if min(q_ef, h_ef, s_ef) == q_ef:
    cost += q * (n*4)
elif h_ef <= s_ef:
    cost += h * (n*2)
else:
    cost += s * n

print(cost)


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

int main(void){
    int N;
    cin >> N;
    vector<long long> B(N - 1);
    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }
    long long ans = B[0] + B[N - 2];
    for(int i = 0; i < N - 2; i++) ans += min(B[i], B[i + 1]);
    cout << ans << endl;
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    vector<int> b(n);
    rep(i, n){
        cin >> b.at(i);
    }

    int ai = 0;
    int bi = 0;
    int idx = 1;
    iota(v.begin(), v.end(), 1);
    do {
        vector<int> i;
        for(auto x : v){
            i.push_back(x);
        }
        if (i == a){
            ai = idx;
        }
        if (i == b){
            bi = idx;
        }
        idx ++;
    } while( next_permutation(v.begin(), v.end())); 
    cout << abs(ai - bi) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int r;
    int x, n;
    int f = 0;
    cin >> x >> n;

    int l, i=0, a[n];

    int u = x + 1;
    int d = x - 1;

    while(cin>>l){
        a[i] = l;
        i++;
    }
    
    std::sort(a, a + n);
    for (int i = 0; i < n; i++) {
        if (n == 0) {
            break;
        }
        if (a[i] == x) f = 1;
        if (a[i] == u) {
            u ++;
        }
        
    }

    std::sort(a, a + n, greater<int>());

    for (int i = 0; i < n; i++) {
        if (n == 0) {
            break;
        }
        if (a[i] == x) f = 1;
        if (a[i] == d) {
            d --;
        }
        
    }

    r = x;

    if (f == 1) {
        r = d;
        if (abs(u-x) < abs (x-d)) r = u;
    }
    
    cout << r;
}

Measured memory_bytes: 3656
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[[0]*2 for i in range(m)]
for i in range(m):
    b[i][0],b[i][1]=map(int,input().split())
a.sort()
b=sorted(b,reverse=True,key=lambda x:x[1])
j=0
c=0
d=0
while(j==0):
    if c>=m:
        break
    for i in range(b[c][0]):
        if d>n-1:
            j=1
            break
        elif b[c][1]>a[d]:
            a[d]=b[c][1]
            d+=1
        else:
            j=1
            break
    c+=1
print(sum(a))

Measured memory_bytes: 26412
def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a

def main():
    N = int(input())
    T = [0] * N

    for i in range(N):
        T[i] = int(input())
    ans = T[0]
    for i in range(1, N):
        ans = ans * T[i] // gcd(ans, T[i])
    print(ans)


main()



Measured memory_bytes: 38256
#include "bits/stdc++.h"

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; ++i) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[N/2] - d[N/2 - 1] << endl;
}


Measured memory_bytes: 640
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_N = 110;
const int MAX_W = 100010;
int N;
int W;
int w[MAX_N];
LL v[MAX_N];
LL dp[MAX_N][MAX_W];

int main()
{
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];
    REP(i, N)
    {
        REP(weight, W + 1)
        {
            if (weight - w[i] >= 0)
            {
                updateMax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
            }
            updateMax(dp[i + 1][weight], dp[i][weight]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>

int main(){
  int K,X;

  std::cin >> K >> X;

  int Min,Max;
  
  Min = X - (K-1);
  Max = X + (K-1);

  for(int i=Min;i<Max;i++){
    std::cout << i << " ";
  }

  std::cout << Max;
  return 0;
}


Measured memory_bytes: 256
using AtCoderBeginnerContest138.Questions;
using AtCoderBeginnerContest138.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest138.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var v = inputStream.ReadDoubleArray();
            Array.Sort(v);

            yield return v.Skip(1).Aggregate(v[0], (a, b) => (a + b) / 2);
        }
    }
}

namespace AtCoderBeginnerContest138
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest138.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest138.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
set<int> st;
int check(int n){
    while(n){
        if(st.find(n % 10) != st.end()){
            return 0;
        }
        n /= 10;
    }
    return 1;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, d;
        cin >> n >> d;
        for(int i = 0; i < d; i++){
            int x;
            cin >> x;
            st.insert(x);
        }
        while(1){
            if(check(n)){
                cout << n << '\n';
                break;
            }
            n++;
        }
    }
}

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

int main() {
  int X, d, m;
  cin >> X;
  d = X / 100;
  m = X % 100;
  if(ceil(m / 5) < d || X % 105 == 0) cout << 1 << endl;
  else cout << 0 << endl;
}

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

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(vector<T> a){
    for (const auto& ai : a) cout << ai << " ";
    cout << endl;
}
vector<string> Yes = {"No", "Yes"};
int main(){
    STR(s, t);
    int a = 1;
    rep(i, Size(s)){
        if (s[i] == t[i]) continue;
        else{
            a = 0;
            break;
        }
    }
    cout << Yes[a] << endl;
}


Measured memory_bytes: 3564
status=0
split=0
n=io.read("*n")
a=io.read("*n")
for i=1,n-1 do
    b=io.read("*n")
    if a>b then
        if status==1 then
            split=split+1
            status=0
        elseif status==0 then
            status=-1
        end
    elseif a<b then
        if status==-1 then
            split=split+1
            status=0
        elseif status==0 then
            status=1
        end
    end
    a=b
end
print(split+1)

Measured memory_bytes: 888
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
H_temp = [None] * len(H)

for i in range(len(H)):
    H_temp[i] = (abs((T - 0.006 * H[i]) - A), i+1)

H_temp.sort()
print(int(H_temp[0][1]))

Measured memory_bytes: 62848
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  long long a, b, q;
  cin >> a >> b >> q;

  vector<long long> s(a), t(b);
  for (int i = 0; i < a; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> t[i];
  }

  while (q--) {
    long long x; cin >> x;
    long long ans = 2e10+10;

    int sr = lower_bound(s.begin(), s.end(), x) - s.begin();
    int sl = sr-1;

    int tr = lower_bound(t.begin(), t.end(), x) - t.begin();
    int tl = tr-1;

    // 右に神社, 右に寺
    if (sr < a && tr < b) {
      long long rd1 = abs(s[sr] - x);
      long long rd2 = abs(t[tr] - x);
      ans = min(ans, max(rd1, rd2));
    }
    // 左に神社, 左に寺
    if (sl >= 0 && tl >= 0) {
      long long ld1 = abs(s[sl] - x);
      long long ld2 = abs(t[tl] - x);
      ans = min(ans, max(ld1, ld2));
    }
    // 右に神社, 左に寺
    if (sr < a && tl >= 0) {
      long long rd = abs(s[sr] - x);
      long long ld = abs(t[tl] - x);
      ans = min(ans, rd+ld+min(rd, ld));
    }
    // 左に神社, 右に寺
    if (sl >= 0 && tr < b) {
      long long rd = abs(t[tr] - x);
      long long ld = abs(s[sl] - x);
      ans = min(ans, rd+ld+min(rd, ld));
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2944