akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define El "\n"
typedef long long int ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,i;
	cin>>n>>i;
	cout<<n-i+1;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long ans = LLONG_MAX;
    for (int i = 0; i <= X || i <= Y; i++) {
        long long res = i*2*C; 
        if (X > i) res += (X-i)*A;
        if (Y > i) res += (Y-i)*B;
        ans = min(ans, res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> val;
vector<int> e;
vector<vector<int> > G;

void dfs(int p){
	for(int i = 0; i < G[p].size(); ++i){
		val[G[p][i]] += val[p];
		dfs(G[p][i]);
	}
}

int main(){
	int n, q, a, b, p, x;
	cin>>n>>q;
	val.resize(n, 0);
	G.resize(n, e);
	for(int i = 0; i < n - 1; ++i){
		cin>>a>>b;
		a--, b--;
		G[a].push_back(b);
	}
	for(int j = 0; j < q; ++j){
		cin>>p>>x;
		p--;
		val[p] += x;
	}
	dfs(0);
	for(int i = 0; i < n; ++i){
		cout<<val[i]<<" ";
	}
	return 0;
}


Measured memory_bytes: 20352
import sys

d = {"I":1, "V":5, "X":10, "L":50, "C":100 ,"D":500,"M":1000}
for line in sys.stdin:
  l = [d[i] for i in line.rstrip()]
  if len(l) == 1:
    print(l[0])
  else:
    s = sum(l)
    for i in range(len(l)-1):
      if l[i] < l[i+1]:
        s -= (2*l[i])
    print(s)

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

map<ll, set<int> > d1, d2;
map<ll, vector<int> > d1s, d2s;
ll an;
int d;
pair<int, int> p1, p2;

void go(int x, int y) {
	stack<pair<int, int> > s;
	s.push(make_pair(x, y));
	while (!s.empty()) {
		x = s.top().first, y = s.top().second;
		s.pop();
		ll z = (ll)x + y + d;
		an += upper_bound(d1s[z].begin(), d1s[z].end(), (ll)x + d) - lower_bound(d1s[z].begin(), d1s[z].end(), x + 1);
		set<int> *st = &d1[z];
		set<int>::iterator it = st->lower_bound(x), itd;
		while (it != st->end() && *it <= (ll)x + d) {
			int t = *it, y = z - t;
			d2[t - y].erase(t);
			itd = it;
			++it;
			st->erase(itd);
			s.push(make_pair(t, y));
		}
		z = (ll)x + y - d;
		an += upper_bound(d1s[z].begin(), d1s[z].end(), x - 1) - lower_bound(d1s[z].begin(), d1s[z].end(), (ll)x - d);
		st = &d1[z];
		it = st->lower_bound((ll)x - d);
		while (it != st->end() && *it <= x) {
			int t = *it, y = z - t;
			d2[t - y].erase(t);
			itd = it;
			++it;
			st->erase(itd);
			s.push(make_pair(t, y));
		}
		z = (ll)x - y + d;
		an += upper_bound(d2s[z].begin(), d2s[z].end(), (ll)x + d - 1) - lower_bound(d2s[z].begin(), d2s[z].end(), x);
		st = &d2[z];
		it = st->lower_bound(x);
		while (it != st->end() && *it <= (ll)x + d) {
			int t = *it, y = -(z - t);
			d1[t + y].erase(t);
			itd = it;
			++it;
			st->erase(itd);
			s.push(make_pair(t, y));
		}
		z = (ll)x - y - d;
		an += upper_bound(d2s[z].begin(), d2s[z].end(), x) - lower_bound(d2s[z].begin(), d2s[z].end(), (ll)x - d + 1);
		st = &d2[z];
		it = st->lower_bound((ll)x - d);
		while (it != st->end() && *it <= x) {
			int t = *it, y = -(z - t);
			d1[t + y].erase(t);
			itd = it;
			++it;
			st->erase(itd);
			s.push(make_pair(t, y));
		}
	}
}

int main() {
	int n, p, q;
	scanf("%d%d%d", &n, &p, &q);
	f(i, 1, n + 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		d1s[x + y].push_back(x);
		d2s[x - y].push_back(x);
		if (i == p)p1 = make_pair(x, y);
		else {
			d1[x + y].insert(x);
			d2[x - y].insert(x);
			if (i == q)p2 = make_pair(x, y);
		}
	}
	for (map<ll, vector<int> >::iterator it = d1s.begin(); it != d1s.end(); ++it)sort(it->second.begin(), it->second.end());
	for (map<ll, vector<int> >::iterator it = d2s.begin(); it != d2s.end(); ++it)sort(it->second.begin(), it->second.end());
	d = abs(p1.first - p2.first) + abs(p1.second - p2.second);
	go(p1.first, p1.second);
	printf("%lld\n", an >> 1);
}

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

using namespace std;

#define ull unsigned long long
#define ll long long
#define ui unsigned int
#define us unsigned short
#define inf_int 1e9
#define inf_ll 1e18

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	
	int h, w, a, b;
	cin >> h >> w >> a >> b;
		
	for(us x=0;x<h;x++){
		for(us y=0;y<w;y++){
			if((x < b && y >= a) || (x >= b && y < a)) cout << 1;
			else cout << 0;
		}
		cout << "\n";
	}

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include<stdio.h>
#include <list>
#include<string>

using namespace std;

int main() {
    char S[10 * 10 * 10 * 10 * 10];
    list<char> list;
    cin >> S;
    for (int i = 0; S[i] != '\0'; i++)
    {
        list.push_back(S[i]);
    }
    int Q;
    cin >> Q;
    int T, F;
    char c;
    bool reverse = false;
    for (int i = 0; i < Q; i++)
    {
        cin >> T;
        if (T == 1)
        {
            reverse = !reverse;
        }
        else
        {
           cin>>F>>c;
            if (F == 1)
            {
                if (!reverse)
                {
                    list.push_front(c);
                }
                else
                {
                    list.push_back(c);
                }

            }
            else
            {
                if (!reverse)
                {
                    list.push_back(c);
                }
                else
                {
                    list.push_front(c);
                }
            }
        }

    }
    if (reverse)
    {
        list.reverse();
    }
    for (auto itr = list.begin(); itr != list.end(); itr++)
    {
        printf("%c", *itr);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 9984
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs (int)1e9+7
#define dive 1e9+9
#define pi 3.141592653589793238
 
typedef pair<int, int> P;

int modPow(long long a, long long n, long long p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int com(int n, int k){
  int ans = 1;
  REP(i,k){
      ans*=n-i;
      ans%=divs;
      ans*=modinv(i+1,divs);
      ans%=divs;
  }
  return ans;
}

signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long n;
    cin>>n;
    long long a;
    cin>>a;
    long long b;
    cin>>b;
    int all = modPow(2,n,divs)-1;
    all-=com(n,a);
    if(all<0) all+=divs;
    all-=com(n,b);
    if(all<0) all+=divs;
    cout<<all<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 N, W;
    cin >> N >> W;

    vs64 w(N);
    vector<vs32> v(4);
    rep (i, N)
    {
        s64 temp;
        cin >> w[i] >> temp;
        v[w[i] - w[0]].push_back(temp);
    }

    rep (i, 4)
    {
        sort(v[i].begin(), v[i].end(), greater<int>());
    }

    s64 A = v[0].size();
    s64 B = v[1].size();
    s64 C = v[2].size();
    s64 D = v[3].size();


    s64 ans = 0;
    rep (a, A + 1) rep (b, B + 1) rep (c, C + 1) rep (d, D + 1)
    {
        s64 sw = w[0] * (a + b + c + d) + b + 2 * c + 3 * d;
        if (sw <= W)
        {
            s64 sum = 0;
            rep (aa, a) sum += v[0][aa];
            rep (bb, b) sum += v[1][bb];
            rep (cc, c) sum += v[2][cc];
            rep (dd, d) sum += v[3][dd];
            ans = MAX(ans, sum);
        }
    }

    cout << ans << "\n";
    return 0;
}



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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define dep(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  int sum=0;
  int tmp=min(x,y);
  if(a+b>2*c)
  {
    sum+=2*c*tmp;
    x-=tmp;
    y-=tmp;
  }
  if(x>0&&a>c*2)
  {
    sum+=2*c*x;
    x=0;
  }
  if(y>0&&b>c*2)
  {
    sum+=2*c*y;
    y=0;
  }
  sum+=a*x+b*y;
  print(sum);

  return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,K,sum;
  sum = 0;
  cin >> N >> K;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
sort(vec.begin(), vec.end());
for (int i = 0; i < K; i++){
  sum += vec.at(N-1);
  N --;
}
  cout << sum << endl;
  
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void){
    int m,f,r;
    
    while(1){
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        else if(m == -1 || f == -1){
            cout << "F";
        }
        else if(m + f >= 80){
            cout << "A";
        }
        else if(m + f >= 65 && m + f <= 80){
            cout << "B";
        }
        else if(m + f >= 50 && m + f <= 65){
            cout << "C";
        }
        else if(m + f >= 30 && m + f <= 50 && r >= 50){
            cout << "C";
        }
        else if(m + f >= 30 && m + f <= 50){
            cout << "D";
        }
        else{
            cout << "F";
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 2988
#include <iostream>
using namespace std;
#define NMAX 200
#define rep(i, N) for(int i = 1 ; i < N ; i++)
int xmin, xmax, ymin, ymax;
int x[NMAX], y[NMAX];
int dx[] = {-1, 0 , 1, 0};
int dy[] = {0, -1, 0, 1};
int N;


int main()
{
  while(true){
    
    cin >> N;
    if(N == 0) break;
    
    x[0] = y[0] = 0;
    int ni, di;
    xmin = xmax = ymin = ymax = 0;
    rep(i, N){
      cin >> ni >> di;
      x[i] = x[ni] + dx[di];
      y[i] = y[ni] + dy[di];
      
      if(x[i] < xmin) xmin = x[i];
      if(x[i] > xmax) xmax = x[i];
      if(y[i] < ymin) ymin = y[i];
      if(y[i] > ymax) ymax = y[i];
    }
    
    cout << xmax - xmin + 1 << ' ' <<  ymax - ymin + 1 << '\n';
  }
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,y;

main() {
    cin >> n >> y;
    rep(i,n+1) rep(j,n-i+1) if (!(y-i*10000-j*5000-(n-i-j)*1000)) {
        cts(i)cts(j)ct(n-i-j)
        return 0;
    }
    printf("-1 -1 -1\n");
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(b-a)<=d && abs(c-b)<=d) || abs(c-a)<=d ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b = 0, c = 1, e;
	cin >> a;
	while (a > b) {
		b = 0;
		for (int h = 1; h <= c; h++) {
			b += h;
		}
		c++;
	}
	cout << c - 1 << endl;
	cin >> e;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n, k;
	char s[55];
	cin >> n >> k;
	rep(i, n) cin >> s[i];
	s[k-1] += 32;
	rep(i, n) cout << s[i];
}

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

vector<int> solve(int t, string num, vector<int> ret, int i, int k){
  if(i == -1) return ret;
  bool f = false, g = false;
  vector<int> r1, r2;
  if(ret[0] != -1 && ret[0] + k*10*(num[i]-'0') <= t){
    ret[ret.size()-1] += k*10*(num[i]-'0');
    ret[0] += k*10*(num[i]-'0');
    r1 = solve(t,num,ret,i-1,k*10);
    ret[ret.size()-1] -= k*10*(num[i]-'0');
    ret[0] -= k*10*(num[i]-'0');
    f = (r1[0] != -1);
  }
  if(ret[0] != -1 && ret[0] + (num[i]-'0') <= t){
    ret.push_back(num[i]-'0');
    ret[0] += (num[i]-'0');
    r2 = solve(t,num,ret,i-1,1);
    ret.pop_back();
    ret[0] -= (num[i]-'0');
    g = (r2[0] != -1);
  }
  if(f && g){
    if(r1[0] == r2[0]){
      return (vector<int>){r1[0],-1};
    }else{
      return max(r1,r2);
    }
  }
  if(f) return r1;
  if(g) return r2;
  return vector<int>(1,-1);
}

int main(){
  int t;
  string num;
  while(cin >> t >> num, t){
    int n = num.length();
    vector<int> init(1,num[n-1]-'0');
    init.push_back(num[n-1]-'0');
    vector<int> ans = solve(t,num,init,n-2,1);
    if(ans[0] == -1) cout << "error" << endl;
    else if(ans[1] == -1) cout << "rejected" << endl;
    else{
      cout << ans[0];
      for(int i = ans.size()-1; i > 0; --i)
        cout << " " << ans[i];
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3028
n = int(input())
cards = {}               #空の辞書を作る

for i in range(n):
    card = input()
    cards[card] = True
    
# print(d)

for c in ["S", "H", "C", "D"]:
    for i in range(1, 14):
        key = c + ' ' + str(i)
        if not key in cards:
            print(key)


Measured memory_bytes: 5596
//package project1;
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Main {
      public static void main(String args[]) {
    	  Scanner sc = new Scanner(System.in);
    	  int n = sc.nextInt();
    	  sc.nextLine();
    	  int a=0,w=0,t=0,r=0;
    	  while(n-->0) {
    		 String s = sc.nextLine();
    		 if(s.contains("AC"))
    			 a++;
    		 else if(s.contains("WA"))
    			 w++;
    		 else if(s.contains("TLE"))
    			 t++;
    		 else r++;
    	  }
    	  System.out.println("AC x "+a);
    	  System.out.println("WA x "+w);
    	  System.out.println("TLE x "+t);
    	  System.out.println("RE x "+r);
      }
}


Measured memory_bytes: 59616
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#s,t間に奇数長のパスが存在したならば必ずs,t間には辺が張られる
#グラフが二部グラフでないならば奇数長のサイクルが存在して任意の(s,t)間に奇数長パスが作れる
#グラフが二部グラフであるならば異なるカラーグループ間の頂点には必ず辺が張られる
n,m = map(int,input().split())
G = defaultdict(set)
color = [0 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    G[a-1].add(b-1)
    G[b-1].add(a-1)
#二部グラフ判定
color[0]=1
que = deque([0])
bipartite = True
while len(que):
    p = que.popleft()
    for q in list(G[p]):
        if color[q] == 0:
            color[q] = -color[p]
            que.append(q)
        elif color[q] == color[p]:
            bipartite = False
            break
if bipartite:
    print(color.count(1)*color.count(-1)-m)
else:
    print(n*(n-1)//2-m)

Measured memory_bytes: 84512
N = int(input())
W = [input() for i in range(N)]
L = [W[0]]
ans = "Yes"
for i in range(1,N):
  if W[i] in L:
    ans = "No"
  if W[i][0] != W[i-1][-1]:
    ans = "No"
  L.append(W[i])
print(ans)


Measured memory_bytes: 3060
N = int(input())
ai = list(map(int, input().split()))

box = [0] * N
v = N // 2  # 後半部の最初のindex

for i in range(v, N):
    if ai[i] == 0:
        box[i] = 0
    else:
        box[i] = 1

for i in range(v - 1, -1, -1):
    value = i + 1
    sum = 0
    for j in range(value * 2 - 1, N, value):
        sum += box[j]
    if sum & 1 == 1:
        box[i] = 0 if ai[i] & 1 == 1 else 1
    else:
        box[i] = 0 if ai[i] & 1 == 0 else 1
print(box.count(1))
for i in range(N):
    if box[i] == 1:
        print(i + 1)


Measured memory_bytes: 7276
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = (1ll<<31)-1;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    bool done[105] = {0};
    vector<P> a,b;
    ll c,d;
    cin >> n;
    rep(i,n){
        cin >> c >> d;
        a.push_back(P(d,c));
    }
    rep(i,n){
        cin >> c >> d;
        b.push_back(P(c,d));
    }
    RSORT(a);
    SORT(b);
    int cnt = 0;
    rep(i,n){
        rep(j,n){
            if (a[j].first < b[i].second && a[j].second < b[i].first && done[j] == 0){
                cnt++;
                done[j] = 1;
                break;
            }
        }
    }
    PRINT(cnt);
}


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

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    map<char, int> M;
    for (int i = 0; i < N;i++)
    {
        M[S[i]]++;
    }
    for (int i = 0; i < N;i++)
    {
        if(M[S[i]] != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

H, W = map(int, input().split())
c = 0
b = []
for i in range(H):
    a = list(input())
    if a != ["." for _ in range(W)]:
        b.append(a)
    else:
        c += 1

b = np.array(b)
b_T = b.T

B = []
for i in range(W):
    if list(b_T[i]) != ["." for _ in range(H-c)]:
        B.append(b_T[i])
B = np.array(B)
ans = B.T
for i in range(len(ans)):
    print("".join(map(str, ans[i])))

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

void no() {
  cout << "No" << endl;
  exit(0);
}

int main() {
  int n; cin >> n;
  vector<pair<int, int>> op, cl;
  long long total = 0;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    int res = 0, dep = 0;
    for (char c : s) {
      res += (c == '(' ? 1 : -1);
      dep = min(res, dep);
    }
    if (res > 0) op.push_back({dep, res});
    else cl.push_back({dep - res, -res});
    total += res;
  }
  if (total != 0) no();
  total = 0;
  sort(op.rbegin(), op.rend());
  for (auto p : op) {
    if (total + p.first < 0) no();
    total += p.second;
  }
  total = 0;
  sort(cl.rbegin(), cl.rend());
  for (auto p : cl) {
    if (total + p.first < 0) no();
    total += p.second;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 11580
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll P=1e9+7,MAXN=4e6+10;
ll n,k,fac[MAXN],inv[MAXN],dp[2010][2010];
ll qpow (ll a,ll b) {
	ll res=1;
	while (b) {
		if (b&1) {
			res=(res*a)%P;
		}
		a=(a*a)%P;
		b>>=1;
	}
	return res;
}
ll c (ll n,ll m) {
	return (((fac[n]*inv[m])%P)*inv[n-m])%P;
}
int main () {
	scanf("%lld%lld",&n,&k);
	if (k==1) {
		printf("%d\n",1);
		return 0;
	}
	fac[0]=inv[0]=1;
	for (ll i=1;i<=n*k;i++) {
		fac[i]=(i*fac[i-1])%P;
	}
	inv[n*k]=qpow(fac[n*k],P-2);
	for (ll i=n*k-1;i>=1;i--) {
		inv[i]=(inv[i+1]*(i+1))%P;
	}
	for (int i=1;i<=n;i++) {
		dp[i][0]=1;
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=i;j++) {
			dp[i][j]=(dp[i-1][j]+(((dp[i][j-1]*(n-j+1))%P)*c(n*k-i-1-(j-1)*(k-1),k-2))%P)%P;
		}
	}
	printf("%lld\n",dp[n][n]);
	return 0;
}

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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 998244353 
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int x, y;
    DI(x, y);
    for(int a = 0; a < 100; a++)
    {
    	for(int b = 0; b < 100; b++)
    	{
    		if(a + b == x)
    		{
    			if((2*a + 4*b) == y)
    			{
    				SO("Yes");
    				return 0;
    			}
    		}
    	}
    }
    SO("No");
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
// #define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
// #define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
#define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve() 
{   
    int n;
    cin >> n;
    int a[n];
    rep(i,n)
        cin >> a[i];
    int txor = 0;
    rep(i,n)
        txor = (txor^a[i]);
    rep(i,n)
        cout << (txor^a[i]) << ' ';
}     

Measured memory_bytes: 5220
#include <iostream>

int main()
{
	int x1, x2, x3, x4, y1, y2, y3, y4;
	std::cin >> x1 >> y1 >> x2 >> y2;

	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x3 - (x2 - x1);
	y4 = y3 - (y2 - y1);

	
	printf("%d %d %d %d", x3, y3, x4, y4);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    char s[4];
    int isBad = 0;
    scanf("%s", s);
    getchar();

    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            isBad = 1;
        } 
    }    

    printf("%s", (isBad) ? "Bad\n" : "Good\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000003;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;


ll clc( ll y, ll m ){
    ll a = y;
    ll res = 1;
    while( m ){
        if( m % 2 ) res *= a;
        res %= mod;
        a *= a;
        a %= mod;
        res /= 2;
    }
    return res;
}

int main(){
    
    cin>>N;
        
    cout<<180*(N-2)<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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


ll a[2001];
int main() {
	string S,T;
	cin >> S >> T;
	int ls = S.length();
	int lt = T.length();
	bool swapped = false;
	FORR(i, ls - lt , 0) {
		bool ok = true;
		REP(j, lt) {
			if (S[i + j] == T[j] || S[i + j] == '?');
			else ok = false;
		}
		if (ok) {
			REP(k, lt)S[i + k] = T[k];
			swapped = true;
			break;
		}
	}
	if (swapped) {
		REP(i, ls) {
			if (S[i] == '?')S[i] = 'a';
		}
		cout << S << endl;
		return 0;
	}
	else {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, K, P[10000], C[10000];

signed main(){
    cin >> N >> K;
    REP(i, N){
        cin >> P[i];
        P[i]--;
    }
    REP(i, N) cin >> C[i];
    ll ans = LONG_LONG_MIN;
    REP(i, N){
        ll j = i;
        ll score = 0;
        vector<ll> v;
        while(true){
            j = P[j];
            score += C[j];
            v.push_back(score);
            if(j == i) break;
        }
        REP(j, v.size()){
            if(j + 1 > K) break;
            ll loop = (K - (j + 1)) / v.size();
            if(score <= 0) ans = max(ans, v[j]);
            else ans = max(ans, score * loop + v[j]);
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
bool a[26];
int main(){
	char ac,bc,cc,dc;
	cin>>ac>>bc>>cc>>dc;
	int a=ac-'0',b=bc-'0',c=cc-'0',d=dc-'0';
	if(a+b+c+d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a+b+c-d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a+b-c+d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a+b-c-d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a-b+c+d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a-b+c-d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a-b-c+d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}
	else{
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int count=0;
int main(){
  int n,S[500000],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

void merge(int *A,int left,int mid,int right){
  int i,j,k,n1,n2,*L,*R;
  n1=mid - left;
  n2=right - mid;

  L=malloc(n1*sizeof(L));
  R=malloc(n2*sizeof(R));
    for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
    for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;

  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;

    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}



Measured memory_bytes: 82880
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
#define d(n) cerr<<#n":"<<n<<endl;
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define cut(n, Min, Max) max(min(n,Max),Min)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

bool narande(ll a, ll b, ll c){
    return (a<b && b<c)||(a>b && b>c);
}

ll get_cost(ll x, ll a, ll b){
    if(narande(a,x,b)){
        return abs(x-a)+abs(x-b)+min(abs(x-a),abs(x-b));
    }
    return max(abs(x-a),abs(x-b));
}

int main(){
    /*
    ll x,a,b;
    cin>>x>>a>>b;
    cout<<get_cost(x,a,b)<<endl;
    return 0;
    /*/
    int a,b,q;
    cin>>a>>b>>q;
    vl s(a);
    vl t(b);
    cin>>s>>t;
    ll mi;
    ll ss[3],tt[3];
    REP(i,q){
        ll x;
        cin>>x;
        mi=LINF;
        auto si=lower_bound(all(s), x);
        auto ti=lower_bound(all(t), x);
        ll ssa,ssb,tta,ttb;
        ss[0]=(si!=s.begin())?*(si-1):LINF;
        ss[1]=(si!=s.end())?*si:LINF;
        ss[2]=(si+1!=s.end())?*(si+1):LINF;
        
        tt[0]=(ti!=t.begin())?*(ti-1):LINF;
        tt[1]=(ti!=t.end())?*ti:LINF;
        tt[2]=(ti+1!=t.end())?*(ti+1):LINF;
        //d(ss[0]);d(ss[1]);d(ss[2]);d(tt[0]);d(tt[1]);d(tt[2]);
        REP(ssi,3){
            REP(tti,3){
                chmin(mi,get_cost(x, ss[ssi], tt[tti]));
            }
        }
        cout<<mi<<endl;
    }
    return 0;
    //*/
}


Measured memory_bytes: 2944
#include<map>
#include<cstdio>

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

using namespace std;

typedef long long ll;

int main(){
	for(int n,S,W,Q;scanf("%d%d%d%d",&n,&S,&W,&Q),n;){
		static int a[100000];
		int g=S;
		rep(i,n){
			a[i]=(g/7)%10;
			if(g%2==0) g=(g/2);
			else       g=(g/2)^W;
		}

		int ans=0;
		if(Q<10){
			// dp[i+1][j] := ( a[i] を右端とする部分文字列で, 十進整数として見たときに mod Q == j となるものの個数 )
			static int dp[100001][10];
			rep(i,n+1) rep(j,Q) dp[i][j]=0;
			rep(i,n){
				if(a[i]!=0) dp[i+1][a[i]%Q]++;
				rep(j,Q) dp[i+1][(j*10+a[i])%Q]+=dp[i][j];
				ans+=dp[i+1][0];
			}
		}
		else{
			map<int,int> f;
			ll sum=0,ten=1;
			for(int i=n-1;i>=0;i--){
				sum=(a[i]*ten+sum)%Q;
				if(a[i]!=0) f[sum]++;
				ten=ten*10%Q;
			}
			sum=0; ten=1;
			ll tar=0;
			for(int i=n-1;i>=0;i--){
				ans+=f[tar];
				sum=(a[i]*ten+sum)%Q;
				if(a[i]!=0) f[sum]--;
				tar=(a[i]*ten+tar)%Q;
				ten=ten*10%Q;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 9552
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

use num::integer::*;

fn f(a: isize, b: isize, i: isize) -> isize {
   return ((a * i) / b) - a * (i / b);
}
use rand::*;

fn main() {
   let mut rng = rand::thread_rng();
   input! {
      a:isize,b:isize,n:isize
   }
   let mut ans = 0_isize;
   if n < 10000 {
      for i in 0..=n {
         ans = std::cmp::max(ans, f(a, b, i));
      }
   } else {
      if n < b {
         ans = (a * n) / b;
      } else {
         for i in 0..=10000 {
            ans = std::cmp::max(ans, f(a, b, i));
         }
         for _ in 0..1000000 {
            ans = std::cmp::max(ans, f(a, b, (rng.gen::<isize>() / 2).abs() % n + 1));
         }
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2480
import java.util.Scanner;

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

		int num = sc.nextInt();
		int[] x = new int[num];
		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextInt();
		}
		long min = 10000000, max = -1000000, sum = 0;

		for (int i = 0; i < x.length; i++) {

			if (min > x[i]) {
				min = x[i];

			}
		}
		for (int i = 0; i < x.length; i++) {
			if (max < x[i]) {
				max = x[i];

			}

		}
		for (int i = 0; i < x.length; i++) {
			sum += x[i];
		}
		System.out.println(min + " " + max + " " + sum);
		sc.close();
	}
}



Measured memory_bytes: 41136
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <tuple>
#include <climits>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

struct T {int u, v, w;};
int add(int a, int b) {return a < INT_MAX ? a + b: a;}

int main() {
	int v {in()}, e {in()}, r{in()};
	vector<T> E(e);
	vector<int> V(v, INT_MAX);
	V[r] = 0;
	for (T &a: E)
		a = {in(), in(), in()};
	if ([&]{
		for (int i {1}; i < v; i++) {
			bool f {true};
			for (T &a: E) {
				V[a.v] = min(V[a.v], add(V[a.u], a.w));
				f = false;
			}
			if (f)
				return f;
		}
		return false;
		}() || [&] {
		for (T &a: E)
			if (V[a.v] > add(V[a.u], a.w))
				return false;
		return true;
		}())
		for (int n: V)
			if (n < INT_MAX)
				outl(n);
			else
				outl("INF");
	else
		outl("NEGATIVE CYCLE");
}


Measured memory_bytes: 2632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    int n, m;
    cin >> n >> m;
    int table[8][8] = {0};
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        table[a][b] = 1;
        table[b][a] = 1;
    }
    vector<int> v;
    rep(i, n) v.eb(i);
    int c = 0;
    do {
        if (v[0] != 0) break;
        rep3(i, 1, n) {
            if (table[v[i]][v[i - 1]] == 0) break;
            if (i == n - 1) c++;
        }
    } while (next_permutation(all(v)));
    out(c);
}


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 310;

bool vis[N][N][N];
int n,c1,c2,c3;
double mem[N][N][N];

double dp(int i,int j,int k)
{
    if( i < 0 || j < 0 || k < 0 )
        return 0.0;

    if( !i && !j && !k )
        return 0.0;

    double &ret = mem[i][j][k];
    if( vis[i][j][k] )
        return ret;
    vis[i][j][k] = 1;

    return ret = ( 1.0 + (1.0*i)/n*dp(i-1,j,k) + (1.0*j)/n*dp(i+1,j-1,k) + (1.0*k)/n*dp(i,j+1,k-1) ) / ( 1.0 - (1.0*n-i-j-k)/n);
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if( x == 1 )
            c1++;
        if( x == 2 )
            c2++;
        if( x == 3 )
            c3++;
    }

    printf("%.9f\n",dp(c1,c2,c3));
}


Measured memory_bytes: 129268
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int a, b; cin >> a >> b;
        cout << a * b << '\n';
    }
    return 0;
}

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    int disa = abs(x - a);
    int disb = abs(x - b);
    if (disa < disb)
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'B' << endl;
    }
}

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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define all(a)	a.begin(), a.end()
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

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

	int n;
	string s;

	cin >> n >> s;

	if (s.size() <= n)
		cout << s;
	else {
		for (int i = 0; i < n; ++i)
			cout << s[i];
		cout << "...";
	}	

	return 0;
}

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


int main() {
    string s;
    cin >> s;
    if(s[1] == 'B') {
        s[1] = 'R';
    }
    else {
        s[1]= 'B';
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 3;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(A.begin(), A.end()); //小さい順
  if(A[0] + A[1] == A[2]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3540
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = next()
    if(N[0] == 7 || N[1] == 7 || N[2] == 7) console.log("Yes")
    else console.log("No")

}
Main()
	

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

using namespace std;

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

    unsigned int n, q;
    cin >> n >> q;
    vector<vector<int>> a(n);

    while (q--) {
        int op;
        cin >> op;

        if (op == 0) {
            int t, x;
            cin >> t >> x;
            a[t].emplace_back(x);
        } else if (op == 1) {
            int t;
            cin >> t;
            for (int i = 0; i < a[t].size(); ++i) {
                cout << a[t][i];
                if (i != a[t].size() - 1) cout << " ";
            }
            cout << endl;
        } else if (op == 2) {
            int t;
            cin >> t;
            a[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5832
#include <stdio.h>

int S[10];

int main() {

	int A, B, C;

	scanf("%d %d %d",&A,&B,&C);

	S[A]++;
	S[B]++;
	S[C]++;

	if (S[5] == 2 && S[7] == 1) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128