akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int>X(100);
	for (int i = 0;i < 100;i++) {
		X.at(i) = 0;
	}
	for (int i = 0;i < N;i++) {
		int A;
		cin >> A;
		X.at(A - 1)++;
	}
	int max = 0, t = 0;
	for (int i = 1;i <= 100;i++) {
		t = 0;
		for (int j = 0;j < 100;j++) {
			if (X.at(j) > 0) {
					t += X.at(j) * ((j + 1) - i) * ((j + 1) - i);
			}
		}
		if (i == 1) {
			max = t;
		}
		if (t < max) {
			max = t;
		}
	}
	cout << max;
}

Measured memory_bytes: 256
import java.util.Scanner; 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h ;
        int w ;
        int t ;
        int y ;
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();
            if(h==0&&w==0)break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    t=i%2;
                    y=j%2;
                    if(t!=0&&y==0||y!=0&&t==0){
                        System.out.print(".");
                    }else{
                        System.out.print("#");   
                    }
                }
                System.out.println(); 
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  string s;
  cin >> s;
  int count=0;
  rep(i,s.size() / 2) {
    if(s.at(i) != s.at(s.size()-1-i)) {
      count++;
    }
  }
  cout << count;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e3+100;

int ans[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        {
            int a=abs(i-j);
            int b=abs(i-x)+1+abs(y-j);
            int c=abs(i-y)+1+abs(x-j);
            int d=min({a,b,c});
            ans[d]++;
        }
    for(int i=1;i<=n-1;i++)
        cout<<ans[i]<<"\n";
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr ll BIG = 1000000000000L;

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

    int X, Y;
    cin >> X >> Y;

    int ans = 0;
    if (X == 3) ans += 100000;
    if (X == 2) ans += 200000;
    if (X == 1) ans += 300000;
    if (Y == 3) ans += 100000;
    if (Y == 2) ans += 200000;
    if (Y == 1) ans += 300000;
    if (X == 1 && Y == 1) ans += 400000;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	rep(i,n){
		cin >> h.at(i);
	}
	vector<int> a(m);
	vector<int> b(m);
	for(int i=0;i<m;i++){
		cin >> a.at(i) >> b.at(i);
	}

	int sum = 0;
	vector<int> cnt(n);
	rep(i,n){
		cnt.at(i) = 1;
	}
	for(int i=0;i<m;i++){
		if(h.at(a.at(i)-1) > h.at(b.at(i)-1)){
			if(cnt.at(a.at(i)-1)==0){
				cnt.at(b.at(i)-1) = 0;
			} else {
				cnt.at(a.at(i)-1)++;
				cnt.at(b.at(i)-1) = 0;
			}
		} else if(h.at(a.at(i)-1) < h.at(b.at(i)-1)){
			if(cnt.at(b.at(i)-1)==0){
				cnt.at(a.at(i)-1) = 0;
			} else {
				cnt.at(b.at(i)-1)++;
				cnt.at(a.at(i)-1) = 0;
			}
		} else {
			cnt.at(b.at(i)-1) = 0;
			cnt.at(a.at(i)-1) = 0;
		}
	}

	rep(i,n){
		if(cnt.at(i)!=0){
			sum++;
		}
	}

	cout << sum << endl;

}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
const ll INF = 1001001001;

const int mod = 1000000007;

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

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

int main() {
    ll n;
    cin >> n;
    priority_queue<P> ab;

    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ab.push(P(b, a));
    }

    ll current_limit = INF;
    while (!ab.empty()) {
        P p = ab.top();
        ll this_limit = p.first;
        ll this_time = p.second;

        current_limit = min(current_limit, this_limit);
        current_limit -= this_time;

        if (current_limit < 0) {
            cout << "No" << endl;
            return 0;
        }
        ab.pop();
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define read(x) int x; cin>>x
#define pi pair<int, int>
#define pl pair<ll, ll>
#define newa(x, type, n) type* x = new type[n] 

typedef long long ll;

using namespace std;

int test()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	read(r);
	read(D);
	read(x);
	int now = x;
	for (int i = 0; i < 10; i++) {
		now = r * now - D;
		cout << now << endl;
	}
	return 0;
}

int main()
{
	test();
	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)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

ll a, b, c, d, e, f, g;
void solve() {
    cin >> a >> b >> c >> d >> e >> f >> g;

    ll ans = 0;
    ans += 2 * b;
    ans += 4 * (a / 2);
    ans += 4 * (d / 2);
    ans += 4 * (e / 2);
    auto tmp = a % 2 + d % 2 + e % 2;
    if (a > 0 && d > 0 && e > 0 && tmp >= 2) {
        if (tmp == 3) ans += 6;
        else ans += -4 + 6;
    }
    cout << ans / 2 << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

using namespace std;


int MAXN = 2e5 + 1;
vector<long long> st;

void update_tree( int pos, long long value, int root, int tleft, int tright) {
  if (pos < tleft || pos > tright || tleft > tright) return;

  if (tleft == tright) {
    st[root] = value;
    return;
  } 

  int mid = (tleft + tright) / 2;
  
  update_tree(pos, value, root*2, tleft, mid);
  update_tree(pos, value, root*2+1, mid+1, tright);
  
  st[root] = max(st[root], value);
}

long long query( int qleft, int qright, int root, int tleft, int tright) {
    if ( tleft >= qleft && tright <= qright) return st[root];

    if (  tleft > qright ) return -1;
    if ( tright < qleft  ) return -1;
    
    int mid = (tleft + tright)/2;

    return max(
      query(qleft, qright, root*2, tleft, mid),
      query(qleft, qright, root*2+1, mid+1, tright)
    );
}


// https://atcoder.jp/contests/dp/tasks/dp_q
int main() {
  int N;
  cin >> N;

  vector<int> H(N+1);
  vector<int> A(N+1);

  st.assign(N*4 + 10, -1);

  // input H
  for(auto i=1; i<=N; i++) cin >> H.at(i);
  // input A
  for(auto i=1; i<=N; i++) cin >> A.at(i);
    
  vector<long long> F(N+1, 0);

  long long myres = -1;
  for (auto i = 1; i <= N; i++) {
      auto res = query(1, H.at(i)-1, 1, 1, N);
      F.at(i) = (  (res==-1)?(0):(res) ) + A.at(i);
      myres = max(myres, F.at(i));
      update_tree(  H.at(i), F.at(i), 1, 1, N);
  }
  cout << myres << endl;
  return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>

int main(){

char S[3];
for (int i = 0; i < 3; i++)
{
    scanf("%c",&S[i]);
}

if (S[0]=='R'){
    if (S[1]=='R'){
        if (S[2]=='R')
        {
            puts("3");
        }else{
            puts("2");
        }
    }else{
        puts("1");
    }
}else{
    if (S[1]=='R'){
        if (S[2]=='R')
        {
            puts("2");
        }else
        {
            puts("1");
        }
    }else{
        if (S[2]=='R')
        {
            puts("1");
        }else
        {
            puts("0");
        }
    }
}

return 0;

}

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

int main()
{
  int h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  string s, t;
  cin >> s >> t;
  int c1(sc), c2(sc), r1(sr), r2(sr);
  string ans = "YES";

  for (int i = 0; i < n; i++) {
    switch (s[i]) {
    case 'L': c1--; break;
    case 'R': c2++; break;
    case 'U': r1--; break;
    case 'D': r2++; break;
    }
    if (c1 <= 0 || c2 > w || r1 <= 0 || r2 > h) {
      ans = "NO";
      break;
    }
    if (t[i] == 'R' && c1 < w) c1++;
    else if (t[i] == 'L' && c2 > 1) c2--;
    else if (t[i] == 'D' && r1 < h) r1++;
    else if (t[i] == 'U' && r2 > 1) r2--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>

using namespace std;

string itos(int num){
	stringstream ss;
	ss << num;
	string snum;
	ss >> snum;
	return snum;
}

int main(){
	int n;
	cin >> n;
	int num[1000];
	
	int ans = 0;
	for(int i = 0;i < n;i++){
		cin >> num[i];
		for(int j = 0;j < i;j++){
			int pnum = num[i] * num[j];
			string snum = itos(pnum);
			
			bool cons = true;
			for(int k = 0;k < snum.size() - 1;k++){
				if(snum[k+1] != snum[k] + 1) cons = false;
			}
			
			if(cons){
				ans = max(ans,pnum);
			}
		}
	}
	
	if(ans == 0){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3204
#include <assert.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  std::vector<int> IN(3);
  cin >> IN[0] >> IN[1] >> IN[2];

  sort(IN.begin(), IN.end());
  cout << IN[2] *10 + IN[1] + IN[0]  << endl;
  return 0;
}


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


int main() {
  vector<int> retu(32);
  retu = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << retu.at(K-1) << endl;
}

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

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


int n, m, x, y, cnt, bcnt[100000];
bool red[100000];

int main() {
	cin >> n >> m;
	lp(n)
		red[i] = false;
	red[0] = true;
	lp(n)
		bcnt[i] = 1;
	lp(m) {
		cin >> x >> y;
		bcnt[x - 1]--;
		bcnt[y - 1]++;
		if (red[x - 1]) {
			red[y - 1] = true;
			if (bcnt[x - 1] == 0)
				red[x - 1] = false;
		}
	}
	cnt = 0;
	lp(n)
		if (red[i])
			cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
   int A,B,K,c;
   cin>>A>>B>>K;
  c=min(A,B);
   vector<int> C(c);
   for(int i=0;i<c;i++){
      int j=i+1;
      if(A%j==0&&B%j==0){
         C.push_back(j);
      }
   }
  reverse(C.begin(),C.end());
   cout<<C[K-1]<<endl;
}


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

using namespace std;

const int inf = 1e9+10;

struct Edge {
    int from,to,weight;

    Edge(int f,int t,int w)
    {
        from=f;to=t;weight=w;
    }

    bool operator < (const Edge &x) const
    {
        return weight < x.weight;
    }
};

int edmonds(vector<Edge> &G, int V, int R)
{
    vector<Edge> minInEdge(V,Edge(-1, -1, inf));
    for (int i=0;i<G.size();i++)
    {
        const Edge &e = G[i];
        minInEdge[e.to] = min(minInEdge[e.to], e);
    }
    minInEdge[R] = Edge(-1, R, 0);

    vector<int> group(V, 0);
    vector<bool> visited(V, false), isCycleGroup(V, false);
    int cnt = 0;
    for (int i = 0; i < V; i++)
    {
        if (visited[i])
            continue;

        int node = i;
        vector<int> path;
        while (node != -1 && !visited[node])
        {
            visited[node] = true;
            path.push_back(node);
            node = minInEdge[node].from;
        }

        bool isCycle = false;
        for (int i=0;i<path.size();i++)
        {
            int v = path[i];
            group[v] = cnt;
            if (v == node)
                isCycleGroup[cnt] = isCycle = true;
            if (!isCycle)
                cnt++;
        }

        if (isCycle)
            cnt++;
    }

    if (cnt == V)
    {
        int answer = 0;
        for(int i=0;i<minInEdge.size();i++)
        {
            Edge &e = minInEdge[i];
            answer += e.weight;
        }

        return answer;
    }

    int answer = 0;
    for (int i=0;i<minInEdge.size();i++)
    {
        Edge &e = minInEdge[i];
        if (isCycleGroup[group[e.to]])
            answer += e.weight;
    }


    vector<Edge> n_G;
    for (int i=0;i<G.size();i++)
    {
        const Edge &e = G[i];
        int u = group[e.from], v = group[e.to], w = e.weight;
        if (u == v)
            continue;
        else
            n_G.push_back(Edge(u, v, w - (isCycleGroup[v] ? minInEdge[e.to].weight : 0)));
    }

    return answer + edmonds(n_G, cnt, group[R]);
}

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

    int v,e,r;
    cin>>v>>e>>r;

    vector<Edge> G;
    for(int i=0;i<e;i++)
    {
        int s,t,w;
        cin>>s>>t>>w;
        G.push_back(Edge(s,t,w));
    }

    cout<<edmonds(G,v,r)<<endl;

    return 0;
}



Measured memory_bytes: 3260
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=1000000;i++){
		if(((i*b)+c)%a==0){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

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

int main() {
  int A, B;
  string S;
  bool flag = true;
  cin >> A >> B >> S;
  for (int i = 0; i < A; i++) {
    if (S.at(i) == '-') {
      flag = false;
    }
  }
  if (S.at(A) != '-') {
    flag = false;
  }
  for (int i = A + 1; i < 1+B+A; i++) {
    if (S.at(i) == '-') {
      flag = false;
    }
  }
  if (flag == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}





Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,n,M[100][100],u,k,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
  scanf("%d%d",&u,&k);
  u--;
  for(j=0;j<k;j++){
    scanf("%d",&v);
    v--;
    M[u][v]=1;
  }
}

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



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

int main(void) {
    string a;
    string b;

    std::cin >> a >> b;

    if (a[0] == b[2] ){
        if(a[1] == b[1]){
            if(a[2] == b[0]){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }else{
                cout << "NO" << endl;
            }
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3528
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	string S, T;
	cin >> S >> T;

	cout << T << S << endl;
	return 0;
}


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

const int INF = 1e9 + 5;

int main() {
	// your code goes here
	int n,a;
	cin>>n;
	vector<int> h(n);
	vector<int> dp(n, INF);
	for(int i = 0; i<n; i++){
		cin>>a ;
		h[i] = a;
		
	}
	dp[0]=0;
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<i+3; j++ ){
			if(j<n){
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  vdb p(n);
  vrep(i, p){
    cin >> i;
    i++;
    i /= 2;
  }

  vdb sum(n + 1);
  sum.at(0) = 0;
  rep(i, 1, n + 1) sum.at(i) = sum.at(i - 1) + p.at(i - 1);
  vdb psum(n - k + 1);
  rep(i, 0, n - k + 1) psum.at(i) = sum.at(k + i) - sum.at(i);
  sort(all(psum));
  db ans = psum.at(n - k);
  cout.precision(20);
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b, m, e;
        cin >> b >> m >> e;
        
        swap_ranges(v.begin()+b, v.begin()+m, v.begin()+e);
    
    }

    for(int i = 0; i < v.size()-1; i++){
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
}


Measured memory_bytes: 3096
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

long long a, b, ans = 1;

int main() {
	INIT
	cin >> a >> b;
	long long c = a - 1, a1 = 0, a2 = 0;
	if (c % 2 == 0) {
		a1 = c;
	}
	if (((c + 1)/ 2) % 2) {
		a1 ^= 1;
	}
	if (b % 2 == 0) {
		a2 = b;
	}
	if (((b + 1)/ 2) % 2) {
		a2 ^= 1;
	}
	ans = a1 ^ a2;
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf 1e9 + 1
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
//#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define MAX 3000
/*void mayank()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}*/
int dp[MAX + 1][MAX + 1];
string getLCS(string& s, string& t, int len)
{
    string LCS;
    int i = 0, j = 0;
    while (len > 0)
    {
        if (s[i] == t[j])
        {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else
        {
            if (dp[i][j + 1] > dp[i + 1][j])
                j++;
            else i++;
        }
    }
    return LCS;
}

int lenLCS(string& s, string& t, int i, int j)
{
    if (i >= s.length() || j >= t.length())
        return 0;

    if (dp[i][j] != -1)
        return dp[i][j];

    if (s[i] == t[j])
        return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);
    else
    {
        return dp[i][j] = max(lenLCS(s, t, i, j + 1), lenLCS(s, t, i + 1, j));
    }
}

string solve(string s, string t)
{
    memset(dp, -1, sizeof dp);
    int len = lenLCS(s, t, 0, 0);
    return getLCS(s, t, len);
}

int main() {
    //mayank();
    string s, t;
    cin >> s >> t;
    cout << solve(s, t);
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline void Max(T &a, T b){if(a < b) a = b;}
template <typename T> inline void Min(T &a, T b){if(a > b) a = b;}
const int N = 4007, mod = 998244353;
int n, K, ans;
int fac[N], invfac[N], inv[N], bin[N], suf0[N], suf1[N];
int C(int n, int m) {
	if(n < m) return 0;
	return 1ll * fac[n] * invfac[m] % mod * invfac[n - m] % mod;
}
void add(int &a, int b) {
	a += b;if(a >= mod) a -= mod;
}
void solve(int n, int cnt, int w) {
	for(int i = 0; i <= w; ++i)
		add(ans, 1ll * (i & 1 ? mod - 1: 1) * C(n + cnt - i - 1, cnt - i - 1) % mod * C(w, i)% mod * bin[w - i] % mod);
}
int main() {
	K = gi(), n = gi();
	inv[1] = fac[0] = invfac[0] = 1, bin[0] = 1;
	rep(i, 1, 4000) {
		if(i ^ 1) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
		fac[i] = 1ll * fac[i - 1] * i % mod;
		invfac[i] = 1ll * invfac[i - 1] * inv[i] % mod;
		bin[i] = 1ll * bin[i - 1] * 2 % mod;
	}
	rep(k, 2, 2 * K) {
		ans = 0;
		int w = min(k / 2, K - (k - 1) / 2), cnt = K - w;
		if(k % 2 == 0 && K >= k / 2) {
			solve(n, cnt, w - 1);
			solve(n - 1, cnt, w - 1);
		}
		else solve(n, cnt, w);
		printf("%d\n", ans);
	}
	return 0;
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    bool can = false;
    for (int i = S.size() - T.size(); i >= 0; --i)
    {
        string X = S.substr(i, T.size());
        bool can2 = true;
        for (int j = 0; j < T.size(); ++j)
        {
            if (X[j] != '?' && X[j] != T[j])
            {
                can2 = false;
                break;
            }
        }
        if (can2)
        {
            for (int j = 0; j < T.size(); ++j)
            {
                S[i + j] = T[j];
            }
            can = true;
            break;
        }
    }
    if (can)
    {
        for (int i = 0; i < S.size(); ++i)
        {
            if (S[i] == '?')
            {
                S[i] = 'a';
            }
        }
        cout << S << endl;
    }
    else
    {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int num1,num2,tmp,r;

  scanf("%d %d",&num1,&num2);
  if(num2 > num1){

    tmp = num2;
    num2 = num1;
    num1 = tmp;
  }

  while(1){
    r = num1%num2;
    num1 = num2;
    num2 = r;
    if(r == 0)break;
  }

  printf("%d\n",num1);
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
typedef unsigned long long ull;
 
int n,k;
int c[MAXN];
ull m[MAXN];
bool v[MAXN];
 
ull dp(int p){
	if(p>=n)
		return 0;
	if(v[p])
		return m[p];
	int z=min(p+k,n);
	ull a=5000000000;
	for(int j=p+1; j<=z; j++)
		a=min(a, abs(c[j]-c[p])+dp(j));
	m[p]=a;
	v[p]=1;
	return a;
}
 
 
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>c[i];
	cout<<dp(1);
}

Measured memory_bytes: 6144
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    for i in range(n):
        x -= a[i]
        if x >= 0:
            ans += 1
        else:
            break
    if x>0:
        ans -= 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){	
	int n;cin>>n;
	ll x=1;
	for(int i=1;i<=n;i++){
		x=x*i%mod;
	}
	cout<<x;
	return 0;
}

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

using namespace std;

int main(){
        int n;
        cin >> n;
        vector <double> v(n);
        for(int i = 0; i < n; i++){
                cin >> v[i];
        }        
        double sum = 0;
        for(int i = 0; i < n; i++){
                sum += 1/v[i];

        }
        cout << setprecision(10) << 1 / sum << endl;
}

Measured memory_bytes: 256
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long a = long.Parse(input[1]);
            long b = long.Parse(input[2]);


            //当たったかどうか確認
            long num = n / (a+b);
            long res = n - (a+b)* num;
            if(res > a)
                Console.WriteLine(num * a + a);
            else
                Console.WriteLine(num * a + res);
    
        }
    }

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c;
	a = b = c = 0;
	while (1) {
		int k[3];
		for (int d = 0; d < 3; d++)cin >> k[d];
		sort(k, k + 3);
		if (k[0] + k[1] <= k[2]) { printf("%d %d %d %d\n", a + b + c, b, a, c); return 0; }
		int e = k[0] * k[0] + k[1] * k[1], f = k[2] * k[2];
		if (e > f)a++;
		else if (e == f)b++;
		else c++;
	}
}

Measured memory_bytes: 3260
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()

ans = ["a"]
for i in range(N-1):
    nans = []

    for S in ans:
        m = max(S)
        for x in range(ord(m)-95):
            nans.append(S+chr(97+x))

    ans = copy.copy(nans)

print("\n".join(ans))

Measured memory_bytes: 17508
// 木の直径
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100000

const int WHITE = 0;// 未訪問
const int GRAY = 1; // 訪問中
const int BLACK = 2;// 訪問完了

const int INV = -1;

typedef struct
{
    int end;
    int weight;
}DATA;

// 木の情報を保持する動的配列
vector<DATA> G[MAX_N];

// 各頂点の訪問状態を保持する配列
int color[MAX_N + 1];

// 頂点:0から一番離れた頂点のNo.
int Zero_Leave_V = -1;
// 最大距離
int Max_Distance = -1;

int N;

void depthFirstSearch(int now_v, int distance);

int main(void)
{
    int start;
    DATA ele;

    // 配列の初期化
    for(int i = 0; i < MAX_N + 1; i++)
    {
        color[i] = WHITE;
    }

    cin >> N;

    for(int i = 0; i < N - 1; i++)
    {
        cin >> start >> ele.end >> ele.weight;

        G[start].push_back(ele);
        // 双方向に設定する
        swap(start, ele.end);
        G[start].push_back(ele);
    }

    // 頂点:0を始点として, 深さ優先探索を実施して、一番遠い点を求める
    depthFirstSearch(0, 0);

    // 訪問情報の初期化
    for(int i = 0; i < MAX_N + 1; i++)
    {
        color[i] = WHITE;
    }

    Max_Distance = -1;

    // 頂点:0から最も離れた点から, 最も離れた点との距離を求める
    depthFirstSearch(Zero_Leave_V, 0);

    cout << Max_Distance << endl;

    return 0;
}

// 深さ優先探索を実施する関数
// now_vertex : 現在の頂点のNo.
// distance : 現在までの距離
void depthFirstSearch(int now_v, int distance)
{

    int end, mid_distance;

    // 訪問中を設定
    color[now_v] = GRAY;

    for(unsigned int i = 0; i < G[now_v].size(); i++)
    {
        end = G[now_v][i].end;

        if( color[end] == WHITE )
        {
            // 距離の計算
        	mid_distance = distance;
        	mid_distance += G[now_v][i].weight;

            // 未訪問の頂点が存在する時は再帰的に関数コールする
            depthFirstSearch(end, mid_distance);
        }
    }

    // 訪問完了
    color[now_v] = BLACK;

    if( Max_Distance < distance )
    {
        Zero_Leave_V = now_v;
        Max_Distance = distance;
    }

    return;
}



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

using namespace std;
int main() {
  string s;
  cin >> s;
  int yy = stoi(s.substr(0, 2));
  int mm = stoi(s.substr(2, 2));
  if (mm > 12 || mm == 0) {
    // not yymm
    if (yy > 12 || yy == 0) {
      // not mmyy
      cout << "NA" << endl;
      return 0;
    } else {
      cout << "MMYY" << endl;
      return 0;
    }
  } else {
    if (yy == 0) {
      cout << "YYMM" << endl;
    } else if (yy <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "YYMM" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))


ans = 0
for i in range(N):
    if a[i] % 2 == 0:
        ans += a[i] // 2
    else:
        if (i == N-1) or (a[i+1] == 0):
            ans += a[i] // 2
        else:
            ans += (a[i] // 2) + 1
            a[i+1] -= 1

print(ans)


Measured memory_bytes: 50520
#include <stdio.h>
#include <string.h>
  
int main(void)
{
    int i, j, a, b, q;
    char str[1001], order[10], p[1001];
    scanf("%s",str);
    scanf("%d",&q);
    for (i=0; i<q; i++) {
        scanf("%s %d %d",order,&a,&b);
        if(strcmp(order,"print")==0) {
            for(j=a; j<=b; j++) {
                printf("%c",str[j]);
            }
            printf("\n");
        } else if(strcmp(order,"reverse")==0) {
            strcpy(p,str);
            for(j=a; j<=b; j++) {
                str[j] = p[a+b-j];
            }
        } else if(strcmp(order,"replace")==0) {
            scanf("%s",p);
            for(j=a; j<=b; j++) {
                str[j] = p[j-a];
            }
        }
    }
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S;
    int K;
    cin>>S>>K;

    K--;
    if(K<S.size()&&count(S.begin(),S.begin()+K+1,'1')==K+1){
        cout<<1<<endl;
        return 0;
    }
    rep(i,S.size())if(S[i]!='1'){
    cout<<S[i]<<endl;
    return 0;}
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <climits>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

ll xs[MAX], vs[MAX], rmx[MAX], lmx[MAX];

void solve(void){
    //input
    int N; ll C, sum = 0LL;
    cin >> N >> C;
    rep(N, i) {
        scanf("%lld %lld\n", &xs[i], &vs[i]);
        sum += vs[i];
    }
    ll accsum = 0LL;
    rep(N, i) {
        accsum += vs[i];
        rmx[i] = max(0LL, accsum-xs[i]);
    }
    accsum = 0LL;
    repr(N, i) {
        accsum += vs[i];
        lmx[i] = max(0LL, accsum-C+xs[i]);
    }
    rep(N-1, i) {
        rmx[i+1] = max(rmx[i], rmx[i+1]);
        lmx[N-i-2] = max(lmx[N-i-2], lmx[N-i-1]);
    }
    ll ans = rmx[N-1];
    //rep(N, i) printf("%lld %lld\n", rmx[i], lmx[i]);
    rep(N-1, i) {
        ans = max(max(max(ans, rmx[i]), lmx[i]), rmx[i]-min(xs[i], C-xs[i+1])+lmx[i+1]);
    }
    cout << ans << endl;

}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  vector<int> ep(n);
  ep[n-1] = an[n-1];
  for(int i=n-2; i>=0; --i){
    ep[i] = ep[i+1] + an[i];
    ep[i] %= MOD;
  }
  ll ans = 0;
  for(int i=0; i<n-1; ++i){
    ans += (ll)an[i] *ep[i+1];
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4832
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import deque

def main():
  n, q = map(int, input().strip().split())
  tree = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().strip().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)
    
  
  counter = [0] * n
  for _ in range(q):
    p, x = map(int, input().strip().split())
    p -= 1
    counter[p] += x

  def bfs(root):
    visited = [False] * n
    dq = deque()
    dq.append(0)
    visited[0] = True
    while dq:
      inode = dq.popleft()
      for ichild in tree[inode]:
        if visited[ichild]:
          continue
        counter[ichild] += counter[inode]
        visited[ichild] = True
        dq.append(ichild)
    
  bfs(tree[1])
  print(' '.join(map(str, counter)))

if __name__=='__main__':
  main()



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

int main(){
	int a[10000],min,max,n,i;
	long long sum=0;
	cin >> n;
			for(i=0;i<n;i++){
				cin>>a[i];
				sum += a[i];
			}
	max = min = a[0];
			for(i = 1;i < n;i++){
				if(a[i] > max)max = a[i];
				if(a[i] < min)min = a[i];
			}
	cout << min <<" "<< max <<" "<< sum <<endl;
return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  string s,t;
  cin>>s>>t;

  int aList[26],bList[26];
  REP(i,26){
    aList[i] = -1;
    bList[i] = -1;
  }

  REP(i,s.length()){
    int x,y;
    x = s[i] - 'a';
    y = t[i] - 'a';
    if(aList[x] == -1){
      aList[x] = y;
    }else if(aList[x]!=y){
      cout<<"No"<<endl;
      return 0;
    }
    if(bList[y] == -1){
      bList[y] = x;
    }else if(bList[y]!=x){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n >> k;
  vi d(k);
  set<int> g;
  rep(i, 0, k)
  {
    cin >> d[i];
    vi a(d[i]);
    rep(j, 0, d[i])
    {
      cin >> a[j];
      g.insert(a[j]);
    }
  }
  cout << n - g.size() << endl;
}

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

using namespace std;


#define PI 3.14159265
#define int long long

int n;

int dfs(string s){
	if(stoll(s) > n){
		return 0;
	}

	// cout << s << endl;

	int res = 1;
	
	if(s.find('3') == string::npos) res = 0;
	if(s.find('5') == string::npos) res = 0;
	if(s.find('7') == string::npos) res = 0;


	res += dfs(s + "3");
	res += dfs(s + "5");
	res += dfs(s + "7");

	// cout << res << endl;

	return res;

}


main(){

	cin >> n;


	cout << dfs("0") << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long> V;
int main() {
  long long X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  long long A[X], B[Y], C[Z];
  for (long long i = 0; i < X; i++) cin >> A[i]; sort(A, A + X, greater<long long>());
  for (long long i = 0; i < Y; i++) cin >> B[i]; sort(B, B + Y, greater<long long>());
  for (long long i = 0; i < Z; i++) cin >> C[i]; sort(C, C + Z, greater<long long>());
  int cnt = 0;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      for (int k = 0; k < Z; k++) {
        if ( (i+1)*(j+1)*(k+1) <= K) {
          V.push_back(A[i]+B[j]+C[k]);
          cnt++;
        }
        else break;
      }
      if( (i+1)*(j+1) > K) break;
    }
  }
  sort(V.begin(), V.end(), greater<long long>());
  for (int i = 0; i < K; i++) cout << V[i] << "\n";
}

Measured memory_bytes: 1400
N = int(input())
a = list(map(int,input().split()))
xx1 = 0
x = []
for i in range(N):
    xx1 += a[N-1-i]*(-1)**(i)
    #print(xx1)
x1 = xx1//2
xi = 0
x.append(x1)
for i in range(1,N):
    xi = a[i-1] - x[i-1]
    x.append(xi)
ans = [str(k*2) for k in x]
print(' '.join(ans))

Measured memory_bytes: 21316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long
// std::sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
//accumulate(&arr2[n], &arr2[m-1], 0);
using namespace std;

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

  ll L,R;
  std::cin >> L >> R;
  ll ans = 2020;
  for (size_t i = L; i <= L+min(R-L,(ll)2019) - 1; i++) {
    for (size_t j = i+1; j <= L + min(R-L,(ll)2019) ; j++) {
      ans = min(ans,((i % 2019)*(j % 2019)%2019));
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}

    // ある要素がどの集合に属しているかを返す
    int find(int x) {
      if (d[x] < 0) return x;
      return d[x] = find(d[x]);
    }

    // 集合をマージする、すでに同じ集合ならfalseが返る
    bool unite(int x, int y) {
      x = find(x); y = find(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x,y);
      d[x] += d[y];
      d[y] = x;
      return true;
    }

    // 2つの要素が同じ集合か判定する
    bool same(int x, int y) { return find(x) == find(y);}
  
    // ある集合の大きさを答える
    int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    map<int, int> mcnt;
    for(int i = 0; i < n; ++i) {
        mcnt[uf.find(i)]++;
    }

    int cnt = 0;
    for(auto z : mcnt) cnt++;
    cout << cnt-1 << endl;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif


double wat[2];
double sug[2];
double E, F;


signed main()
{
	cin >> wat[0] >> wat[1];
	cin >> sug[0] >> sug[1];
	cin >> E >> F;
	wat[0] *= 100;
	wat[1] *= 100;
	vector<double> w1;
	vector<double> w2;
	vector<double> s1;
	vector<double> s2;
	for (int i = 0; wat[0] * i <= F; i++) w1.PB(wat[0]*i);
	for (int i = 0; wat[1] * i <= F; i++) w2.PB(wat[1]*i);
	for (int i = 0; sug[0] * i <= F; i++) s1.PB(sug[0]*i);
	for (int i = 0; sug[1] * i <= F; i++) s2.PB(sug[1]*i);
	vector<double> W;
	vector<double> S;
	rep(i, w1.size()) {
		rep(j, w2.size()) {
			if (w1[i] + w2[j] <= F) W.PB(w1[i]+w2[j]);
		}
	}
	UNIQUE(W);
	rep(i, s1.size()) {
		rep(j, s2.size()) {
			if (s1[i] + s2[j] <= F) S.PB(s1[i]+s2[j]);
		}
	}
	int si=0, wi=0;
	double ma = -1;
	UNIQUE(S);
	reps(i, 1, W.size()) {
		rep(j, S.size()) {
			if (W[i] + S[j] > F) break;
			if (S[j] / W[i] > E / 100) break;
			if (ma < S[j] / (S[j]+W[i])) {
				ma = S[j] / (S[j]+W[i]);
				si = S[j];
				wi = W[i];
			}
		}
	}
	cout << wi + si << " " << si << endl;
}



Measured memory_bytes: 2424
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    vector<pair<int, int>> route;
    pair<int, int> prev;
    double ans = 0;
    int cnt = 0, permu = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        route.push_back(make_pair(x, y));
    }

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

    do {
        for (auto x: route) {
            if (cnt) {
                ans += sqrt((prev.first - x.first) * (prev.first - x.first) + (prev.second - x.second) * (prev.second - x.second));
            }

            prev.first = x.first;
            prev.second = x.second;
            cnt++;
        }
        cnt = 0;
        permu++;
    } while (next_permutation(route.begin(), route.end()));

    printf("%.10lf\n", ans / permu);

}


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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;
signed main() {
  int N, x;
  cin >> N >> x;
  while (N != 0 or x != 0) {
    int c = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        for (int k = j + 1; k <= N; k++) {
          if (i + j + k == x) {
            // cout << i << " " << j << " " << k << endl;
            c++;
          }
        }
      }
    }
    cout << c << endl;
    cin >> N >> x;
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/



Measured memory_bytes: 3092