akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int x, y;  
  
  while(cin >> x >> y) {
    cout << x+y << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
	int n,k;
	while(~scanf("%d%d",&n,&k)){
		int i,a,b,board=1;
		for(i=0;i<n;i++){
			a=board+k;
			b=board*2;
			board=a<b?a:b;
		}
		printf("%d\n",board);
	}
	return 0;
}

Measured memory_bytes: 128
#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

vs32 pre;
vs32 in;
vs32 ans;

void solve(int prel, int prer, int inl, int inr)
{
    if (prel >= prer)
    {
        return;
    }
    int div = inr;
    for (int i = inl; i < inr; ++i)
    {
        if (in[i] == pre[prel])
        {
            div = i;
            break;
        }
    }
    // cout << "prel, prer, inl, inr, div = " << prel << ", " << prer << ", " << inl << ", " << inr << ", " << div << "\n";
    solve(prel + 1, prel + 1 + div - inl, inl, div);
    solve(prel + 1 + div - inl, prer, div + 1, inr);
    // cout << "push ans2 = " << pre[prel] << ", " << prel << "\n";
    ans.push_back(pre[prel]);
}

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

    int n;
    cin >> n;

    pre.resize(n);
    in.resize(n);
    rep (i, n) cin >> pre[i];
    rep (i, n) cin >> in[i];

    solve(0, n, 0, n);

    rep (i, n)
    {
        if (i > 0) cout << " ";
        cout << ans[i];
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string> s;
  for(int i=0;i<n;i++){
    string a;
    cin>>a;
    s.push_back(a);
  }
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
    cout<<s[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[102][102],a[21002],b[21002],c[201002];
int main() {
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<102;i++){
		for(ll j=0;j<102;j++){
			ch[i][j]=inf;
			if(i==j){
				ch[i][j]=0;
			}
		}
	}
	for(ll i=0;i<m;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		ch[x][y]=ch[y][x]=z;
		a[i]=x;
		b[i]=y;
		c[i]=z;
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				ch[i][j]=min(ch[i][j],ch[i][k]+ch[k][j]);
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<m;i++){
		if(ch[a[i]][b[i]]==c[i]){
			ans++;
		}
		//cout << ch[1][2]<<endl;
	//	cout << ans;
	}
	cout << m-ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
H,W = map(int,input().split())
a = []
[a.append(list(input())) for _ in range(H)]

while ["."]*W in a:
    a.remove(["."]*W)
    H -= 1

a_t = [list(x) for x in zip(*a)]

while ["."]*H in a_t:
    a_t.remove(["."]*H)

a = [list(x) for x in zip(*a_t)]
a_ = [''.join(x) for x in a]
[print(x) for x in a_]

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#include <vector>
#include <limits>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long;
const int N_MAX = 200005;
Int xy[2*N_MAX];
int n;

// case min = R, max = B
Int calcOptValue1(Int minElm, Int maxElm) {
    Int rMin = minElm;
    Int bMax = maxElm;
    Int rMax = rMin;
    Int bMin = bMax;
    REP(i, n) {
        Int l = xy[2*i], h = xy[2*i + 1];
        if (l > h) swap(l,h);
        if (rMax < l) rMax = l;
        if (h < bMin) bMin = h;
    }
    return (rMax - rMin) * (bMax - bMin);
}

// case min = R, max = R
Int calcOptValue2(Int minElm, Int maxElm) {
    int minCnt = 0;
    int maxCnt = 0;
    Int bMin = maxElm;
    Int bMax = minElm;
    vector<pair<Int,Int>> v;
    
    REP(i, n) {
        Int l = xy[2*i], h = xy[2*i + 1];
        if (l > h) swap(l,h);
        v.push_back(make_pair(l,h));
        if (h == minElm) minCnt++;
        if (h == maxElm) maxCnt++;
        if (l < bMin) bMin = l;
        if (bMax < l) bMax = l;
    }
    sort(&v[0], &v[n]);
    Int bDiff = numeric_limits<Int>::max();
    Int swapedBMin = maxElm;
    REP(i, n){
        bMin = v[i].first;
        if (swapedBMin < bMin) {
            if (minCnt > 0 && maxCnt > 0) {
                bDiff = min(bDiff, bMax - swapedBMin);
            }
            break;
        }
        if (minCnt > 0 && maxCnt > 0){
            bDiff = min(bDiff, bMax - bMin);
        }
        // swap i
        bMax = max(bMax, v[i].second);
        swapedBMin = min(swapedBMin, v[i].second);
        if (v[i].first == minElm) minCnt++;
        if (v[i].first == maxElm) maxCnt++;
        if (v[i].second == minElm) minCnt--;
        if (v[i].second == maxElm) maxCnt--;
    }
    if (bDiff == numeric_limits<Int>::max()) return bDiff;
    return (maxElm - minElm) * bDiff;
}
void solve() {
    cin >> n;
    if (n == 1){
        cout << 0 << endl;
        return;
    }
    REP(i, 2*n) cin >> xy[i];
    Int minElm = *min_element(xy, xy + (2*n));
    Int maxElm = *max_element(xy, xy + (2*n));
    
    cout << min(calcOptValue1(minElm, maxElm), calcOptValue2(minElm, maxElm)) << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 9584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int A,B,X;

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

    if(A+B>X){
        if(A<=X){
            printf("YES\n");
            return 0;
        }
    }
    
    printf("NO\n");
    
    return 0;
}


Measured memory_bytes: 256
let [| l; m; |] = stdin.ReadLine().Split() |> Array.map int

match seq{l..m} |> Seq.exists (fun x -> x % 2019 = 0 ) with 
|true -> 0
|false -> 
    seq{for i in l%2019..m%2019 do for j in i+1..m%2019 -> i,j} |> Seq.map (fun (x1, x2) -> (x1, x2))
    |> Seq.map (fun (x1,x2) -> x1 * x2 % 2019)
    |> Seq.min
|> stdout.WriteLine


Measured memory_bytes: 15608
from collections import Counter
 
n = int(input())
a = list(map(int,input().split()))
q = int(input())
 
ans=sum(a)
A=Counter(a)

for i in range (q):
  b,c = map(int, input().split())
  ans=ans+(c-b)*A[b]
  A[c]+=A[b]
  A[b]=0
  print(ans)

Measured memory_bytes: 23980
#include<iostream>
#include<cstdio>
#include<algorithm>

#define int long long
using namespace std;

const int maxn = 2e5 + 5;
int a[maxn],n,k,ans;

int check(int x) {
	int sum = 0;
	for (int i=1; i<=n; i++) {
		if (a[i] > 0) {
			int l = 1,r = n,ans = 0;
			while (l <= r) {
				int mid = (l + r) / 2;
				if (a[i] * a[mid] <= x)
					l = mid + 1,ans = mid; else
					r = mid - 1;
			}
			if (a[i] * a[i] <= x)
				ans--;
			sum += ans;
		}
		if (a[i] < 0) {
			int l = 1,r = n,ans = n + 1;
			while (l <= r) {
				int mid = (l + r) / 2;
				if (a[i] * a[mid] <= x)
					r = mid - 1,ans = mid; else
					l = mid + 1;
			}
			ans = n - ans + 1;
			if (a[i] * a[i] <= x)
				ans--;
			sum += ans;
		}
		if (a[i] == 0)
			if (x >= 0)
				sum += (n - 1);
	}
	return sum / 2;
}
	
signed main() {
//	freopen("data.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%lld%lld",&n,&k);
	for (int i=1; i<=n; i++)
		scanf("%lld",&a[i]);
	sort(a + 1,a + n + 1);
	int l = -1e18 - 5,r = 1e18 + 5;
	ans = l;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check(mid) >= k) {
			ans = mid;
			r = mid - 1;
		} else
		 	l = mid + 1;
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4760
import math
N = int(input())
sN = int(math.sqrt(N))
Answer = N
for i in range(2,sN+1):
    if N % i == 0:
        A1 = (N//i) + i
        Answer = min(Answer,A1)
    else:
        continue
if Answer ==N:
    print(Answer-1)
else:
    print(Answer-2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
bool exist(int x,vector<int> v)
{
	for(int i=0;i<v.size();i++)
	{
		if(v[i]==x)
			return true;
	}
	return false;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	vector <int> v[m];
	for(int i=0;i<m;i++)
	{
		int s;
		cin>>s;
		for(int j=0;j<s;j++)
		{
			int x;
			cin>>x;
			v[i].push_back(x-1);
		}
	}
	int k[m];
	for(int i=0;i<m;i++)
	{
		cin>>k[i];
	}
	int ans=0;
	for(int i=0;i<pow(2,n);i++)
	{
		int x=i;
		vector <int> temp;
		for(int j=0;j<n;j++)
		{
			temp.push_back(x%2);
			x/=2;
		}
		int t[m]={0};
		for(int j=0;j<m;j++)
		{
			for(int k=0;k<n;k++)
			{
				if(temp[k]==1&&exist(k,v[j]))
				{
					t[j]++;
				}
			}
		}
		int f=0;
		for(int j=0;j<m;j++)
		{
			if(t[j]%2!=k[j])
				f=1;
		}
		if(f==0)
			ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
int main()
{

int h, w;
int x, y;

while (1){
scanf("%d %d", &h, &w);
if (h == 0 && w == 0) break;
for  (y = 0; y < h; y++ ){
    for (x = 0; x < w; x++){
        printf("#");}
        printf("\n");
            }
        printf("\n"); 
}
return 0;
}

Measured memory_bytes: 572
#include<stdio.h>

int main(){
    int H, W, i, j;

    while(scanf("%d%d", &H, &W), H){
        for(i=0; i<H; i++){
            if(i==0 || i==H-1) for(j=0; j<W; j++) printf("#");
            else{
                for(j=0; j<W; j++){
                    if(j==0 || j==W-1) printf("#");
                    else printf(".");
                } 
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



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

using namespace std;

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

    int N;
    cin >> N;

    vector<string> v(N);
    vector<pair<int, int>> w(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i];

        int prefix = 0;
        for (int j = 0; j < (int) v[i].size(); ++j) {
            prefix += (v[i][j] == '(' ? 1 : -1);
            w[i].second = min(w[i].second, prefix);
        }
        w[i].first = prefix;
    }

    auto comp = [](pair<int, int> &a, pair<int, int> &b) {
        if (a.first >= 0 && b.first < 0) {
            return true;
        } else if (b.first >= 0 && a.first < 0) {
            return false;
        } else if (a.first >= 0 && b.first >= 0) {
            return a.second > b.second;
        } else {
            return a.first - a.second > b.first - b.second;
        }
    };

    sort(w.begin(), w.end(), comp);

    int prefix = 0;
    for (int i = 0; i < N; ++i) {
        if (prefix + w[i].second < 0) {
            cout << "No\n";
            return 0;
        }
        prefix += w[i].first;
    }

    if (prefix == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 42224
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool prime[50010];
	for (int i = 0; i < 50010; i++) {
		prime[i]=true;
	}
	prime[0] = prime[1]=false;
	for (int i = 2; i < 50010; i++) {
		if (!prime[i]) { continue; }
		for (int j = i * 2; j < 50010; j += i) {
			prime[j]=false;
		}
	}
	
	while (true) {
		int n;
		cin >> n;
		
		if (n == 0) { return 0; }
		int ans = 0;
		for (int i = 0; i <= n / 2; i++) {
			if (prime[i] && prime[n - i]) {
				ans++;
			}
		}
		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <map>

using namespace std;

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

    map<string, int> m;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1; 

    cout << m[S] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion


int main()
{
    int a, b;
    cin >> a >> b;
    P(a*b);
    return 0;
}

Measured memory_bytes: 3092
# https://beta.atcoder.jp/contests/abc110/tasks/abc110_b


def solve():
    _, _, X, Y = map(int, input().split())
    xn = max(map(int, input().split()))
    ym = min(map(int, input().split()))

    Z = xn + 1

    if X < Z <= Y and xn < Z <= ym:
        print('No War')
        exit()
    else:
        print('War')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (int i = 1;i < N;++i) {
		string a = S.substr(0, i), b = S.substr(i);
		vector<bool> judgea(26, false);
		vector<bool> judgeb(26, false);
		rep(j, a.size()) {
			judgea[a[j] - 'a'] = true;
		}
		rep(j, b.size()) {
			judgeb[b[j] - 'a'] = true;
		}
		int count = 0;
		rep(j, 26) {
			if (judgea[j] && judgeb[j]) {
				count++;
			}
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 505

int main(){

    ll n;
    cin >> n;

    vector<ll> x(n),y(n),h(n);
    ll height = 0;

    REP(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0){
            //高さ0でないもの
            height = i;
        }
    }

    //i:y j : x
    for(ll i = 0;i <= 100;i++){
        for(ll j = 0;j <= 100;j++){

            ll tmp = h[height] + abs(i - y[height]) + abs(j - x[height]);//仮の高さ
            bool exist = true;

            REP(k,n){
                if(h[k] != max(tmp - abs(x[k]-j) - abs(y[k]-i),0LL)){
                    exist = false;
                    break;
                }
            }
            if(exist){
                //中心座標と高さが正しいものがあった
                cout << j << " " << i << " " << tmp << endl;
                return 0;
            }
        }
    }




    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		// 配列を準備
		// int[] array = new int[N];
		// 最初からリスト
		List<Integer> list = new ArrayList<>();
		// for文でN回繰り返し
		for (int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		// Collections.reverse(list);
		// 本当に反対にする必要があるか？
		// 大きい方から小さい方に？ 小さい方から大きい方に？⇒後で。

		// for(int i = 0; i < list.size();i++) {
		// 配列に対する操作であって、Collectionsに合わせたループがある
		int result = 0;
		ListIterator<Integer> i = list.listIterator();
		while (i.hasNext()) {
			// if (flag) {
			if (i.nextIndex() % 2 == 0) {
				// true なので Alice
				// 該当カードを取得する
				// AliceMaxCount += i.next();
				result += i.next();
			} else {
				// Bob
				// BobMaxCount += i.next();
				result -= i.next();
			}
		}
		System.out.println(Math.abs(result));
		sc.close();
	}
}

Measured memory_bytes: 21204
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long LL;
int n,k;

int main(){
    scanf("%d%d",&n,&k);
    LL t=n/k;
    LL ans=t*t*t;
    if(k%2==0){
        if(n%k>=k/2)++t;
        ans+=t*t*t;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
M=10**9+7
q=->a,b{b<1?1:a**b[0]*q[a,b/2]**2%M}
f=->r,c{s=t=1
c.times{|i|t=t*-~i%M
s=s*(r+c-i)%M}
s*q[t,M-2]%M}
eval"A,B,C,D="+`tr \\  ,`
p (f[A,B]-f[C+=1,B]-f[A,D+=1]+f[C,D])%M

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

int main(){
    int n, m, p, x, sum = 0;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t.at(i);
        sum += t.at(i);
    }
    cin >> m;
    
    for (int i = 0; i < m; i++)
    {
        cin >> p >> x;
        cout << sum - t.at(p - 1) + x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a=[]
b=[]
ah=[]
bh=[]
c=int(input())
for x in input().split(" "):
    a.append(int(x))
for x in input().split(" "):
    b.append(int(x))

i=0
n=0

while i<c:
    if a[i]>=b[i]:
        n+=b[i]
        a[i]=a[i]-b[i]
    else:
        n+=a[i]
        b[i]-=a[i]
        a[i]=0
        if a[i+1]>=b[i]:
            n+=b[i]
            a[i+1]-=b[i]
        else:
            n+=a[i+1]
            a[i+1]=0
    i+=1

print(n)

Measured memory_bytes: 19004
def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 1
    x = 10 ** 18
    if 0 in A:
        print(0)
        exit()
    for a in A:
        ans *= a
        if ans > x:
            print(-1)
            exit()
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 84564
/*

	・チーズ工場は1からN(KOUZYOU)までの数値の工場がそれぞれ1つずつある

*/




#include<iostream>
#include<queue>

using namespace std;



//座標構造体
typedef struct struct_zahyou_data
{
	int y;
	int x;
}S_zahyou;


//入力の最大値
const int HEIGHT = 1000;	//縦
const int WIDTH = 1000;		//横
const int KOUZYOU = 9;		//工場

//-1で初期化
const int INF = -1;

//進む方向
const int h_tate[4] = {1 , -1 , 0 , 0};
const int h_yoko[4] = {0 , 0 , 1 , -1};


//入力文字列
char str_map[HEIGHT][WIDTH + 1];

//幅優先探索で使う配列
int wh_map[HEIGHT][WIDTH];

//答えを求める辺数
int ans = 0;


//自分の位置
S_zahyou s_me;


//工場の位置を把握する配列
S_zahyou s_kouzyou[10];


//配列初期化関数
void f_reset();


//幅優先探索を行う関数
void f_bfs(int , int , int);

//構造体を返す変数
S_zahyou f_zahyou(int , int);

//工場の位置を求める関数
void f_kouzyou(int , int);


int main(void)
{
	//縦の長さ
	int height = 0;
	//横の長さ
	int width = 0;
	//工場の数
	int kouzyou = 0;

	//縦・横・工場の入力
	cin >> height >> width >> kouzyou;

	//文字列の入力
	for (int i = 0; i < height; i++)
	{
		cin >> str_map[i];
	}

	//スタート位置を格納する
	f_kouzyou(height , width);

	//探索
	for (int i = 0; i < kouzyou; i++)
	{
		//歩数配列の初期化
		f_reset();
		//関数で計算
		f_bfs(i , height , width);
	}

	cout << ans << endl;

	return 0;
}



//配列初期化関数
void f_reset()
{
	for (int i = 0; i < HEIGHT; i++)
	{
		for (int j = 0; j < WIDTH; j++)
		{
			wh_map[i][j] = INF;
		}
	}
}


//幅優先探索を行う関数
void f_bfs(int now , int max_height , int max_width)
{
	//ゴール
	int goal = now + 1 + '0';

	//queueの宣言
	queue<S_zahyou> q_data;

	//初期位置を代入
	q_data.push(s_kouzyou[now]);
	//初期位置を0とする
	wh_map[s_kouzyou[now].y][s_kouzyou[now].x] = 0;
	
	//途中で抜けるはずだが念のため
	while (!q_data.empty())
	{
		//座標を取り出す
		int yy = q_data.front().y;
		int xx = q_data.front().x;
		q_data.pop();

		//四方を見る
		for (int i = 0; i < 4; i++)
		{
			//次の位置
			int nextY = yy + h_tate[i];
			int nextX = xx + h_yoko[i];

			//次の位置が許容されるかどうか
			if (nextY >= 0 && nextY < max_height &&
				nextX >= 0 && nextX < max_width)
			{
				//INF且つXではない
				if (wh_map[nextY][nextX] == INF && str_map[nextY][nextX] != 'X')
				{
					//前の歩数+1の値を格納してキューに追加
					wh_map[nextY][nextX] = wh_map[yy][xx] + 1;
					q_data.push(f_zahyou(nextY , nextX));

					//もしも目指しているものならば答え変数に足して関数から抜ける
					if (str_map[nextY][nextX] == goal)
					{
						ans += wh_map[nextY][nextX];
						return;
					}
				}
			}
		}
	}
}




//構造体を返す変数
S_zahyou f_zahyou(int yy , int xx)
{
	S_zahyou s_data;
	s_data.y = yy;
	s_data.x = xx;

	return s_data;
}



//工場の位置を求める関数
void f_kouzyou(int width , int height)
{
	//文字列の終端まで回して工場の位置を格納
	for (int i = 0; i < width; i++)
	{
		for (int j = 0; j < height; j++)
		{
			//スタートは[0]に格納
			if (str_map[i][j] == 'S')
			{
				s_kouzyou[0].y = i;
				s_kouzyou[0].x = j;
			}
			//文字を発見した場合
			if (str_map[i][j] >= '1' && str_map[i][j] <= '9')
			{
				//縦と横を格納
				s_kouzyou[str_map[i][j] - 48].y = i;
				s_kouzyou[str_map[i][j] - 48].x = j;
			}
		}
	}
}

Measured memory_bytes: 6104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int n = s.length();
            int[] ans = new int[n];
            int i = 0;
            while (i < n) {
                int lR = len(s, n, i, 'R');
                int j = i + lR;
                int lL = len(s, n, j, 'L');
                int sum = lR + lL;
                int v1, v2;
                if (sum % 2 == 0)
                    v1 = v2 = sum / 2;
                else {
                    int half1 = sum / 2 + 1;
                    int half2 = sum - half1;
                    if (lR % 2 == 0) {
                        v1 = half2;
                        v2 = half1;
                    } else {
                        v2 = half2;
                        v1 = half1;
                    }
                }
                ans[j - 1] = v1;
                ans[j] = v2;
                i = j + lL;
            }
            for (int el : ans)
                out.print(el + " ");
        }

        private static int len(String s, int n, int beg, char c) {
            int cnt = 0;
            int j = beg;
            while (j < n && s.charAt(j) == c) {
                j++;
                cnt++;
            }
            return cnt;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

int main(){
  int k;
  string s,t;
  cin >> k >> s ;
  if (s.size()>k){
    rep(i,k) t+=s.at(i);
    t+="...";
  }
  else t=s;
  
  cout << t << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, ans;
	cin >> num;
	ans = num >> 1;
	ans *= ans + (num & 1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define lli long long int
lli a[100009];
lli ans[100009];
int main() 
{ 
  string str;
  cin >> str;
  for(int i=0;i<str.length();i++)
  {
    if(str[i]=='?')
      str[i] = 'D';
  }
  cout << str;
  return 0; 
} 


Measured memory_bytes: 3752
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

use std::ascii::AsciiExt;

fn main() {
    let (_, K) = read!(usize, usize);
    let mut S = rl().chars().collect::<Vec<_>>();
    S[K - 1].make_ascii_lowercase();
    println!("{}", S.into_iter().collect::<String>())
}


Measured memory_bytes: 4352
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
Standard=[400,600,800,1000,1200,1400,1600,1800,2000]
X = int(input())
from bisect import bisect_right
class_x =bisect_right(Standard,X)
print(9-class_x)


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

int main(){
    int n;
    string ans = "No";
    cin >> n;
    
    int sum = 0,maxlen = 1;
    for (int i = 0; i < n; i++) {
        int buf;
        cin >> buf;
        sum += buf;
        maxlen = max(maxlen,buf);
    }
    
    if (maxlen < sum - maxlen) {
        ans = "Yes";
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {
	long H, W, D, tmp, Q;
	cin >> H >> W >> D;
	
	vector<pair<long, long>>num(H*W+1);
	
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> tmp;
			num[tmp] = pair<long, long>(i + 1, j + 1);
		}
	}

	cin >> Q;
	vector<long>L(Q);
	vector<long>R(Q);
	rep(i, 0, Q) {
		cin >> L[i];
		cin >> R[i];
	}

	vector<long>d(H*W + 1, 0);
	rep(i, D + 1, H*W+1) {
		d[i] = d[i - D] + abs(num[i].first - num[i - D].first) + abs(num[i].second - num[i - D].second);
	}

	rep(i, 0, Q) {		
		cout << d[R[i]]-d[L[i]] << endl;
	}



	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 207;

int n;
int a[M];

void read() {
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i += 2)
    ans += a[i];
  cout << ans;
}


void kill() {

}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200) // 不小于 3200
    {
        cout << s << endl;
    } else { // 小于 3200
        cout << "red\n";
    }
    return 0;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Text.Printf         (printf)

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    printf "%d %d %.5f\n"
        (a `div` b)
        (a `mod` b)
        (fromIntegral a / fromIntegral b :: Double)



Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K,X;
  cin >>A >>B >>C >>K;
  X=0;
  for(int i=0;i<K;i++){
    if(B<=A){
      B=B*2;
      X++;
    }
    else {
      break;
    }
  }
  for(int i=0;i<K-X;i++){
    C=C*2;
  }
  if(A<B&&B<C){
    cout <<"Yes";
  }
  else{
    cout <<"No";
  }
}

Measured memory_bytes: 3516
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
int n,k,s;
int main()
{
	scanf("%d%d%d",&n,&k,&s);
	if(s!=1000000000)
	{
		for(int i=1;i<=k;i++) a[i]=s;
		for(int i=k+1;i<=n;i++) a[i]=1000000000;
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
    }
    else
    {
    	for(int i=1;i<=k;i++) a[i]=s;
		for(int i=k+1;i<=n;i++) a[i]=1;
		for(int i=1;i<n;i++) printf("%d ",a[i]);
		printf("%d",a[n]);
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int N, K;
    cin >> N >> K;

    vector<ll> x(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    ll ans=1000000000;
    for (int i = 0; i <= N-K; i++) {
        ll a,b;
        a = abs(x[i+K-1] - x[i]) + abs(x[i+K-1]);
        b = abs(x[i+K-1] - x[i]) + abs(x[i]);
        a = min(a, b);
        ans = min(ans, a);
    }

    cout << ans << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


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

int main()
{long long int n,r,sum=0,subsum=0,o=0,k,l,yy=0;
    vector <long long int > y;
   cin>>n;
    for(int i=0;i<n;i++){cin>>r,y.push_back(r);sum+=r;}
    for(int i=0;i<n-1;i++)
    {subsum+=y[i];
    l=sum-subsum;
    k=subsum-l;
if(yy==0){o=abs(k);yy++;}
        o=min(o,abs(k));
}
cout<<o;
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
typedef pair<int, int>pii;
typedef pair<int, bool>pib;
// vector<VEC> v (n, VEC(n))
//loop(i,n)loop(j,n)dp[i][j]=-1;
//printf("%d\n", n);

int main()
{
	cin.tie(0);
	cin.sync_with_stdio(0);
	char a, b;
	cin >> a >> b;
	if(a>b)cout <<'>'<< endl;
	else if(a<b)cout << '<' << endl;
	else cout << '=' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long K){
    vector<ll> ans(50,49);
    for (int i = 0; i < 50; i++)
    {
        ans[i] += K/50;
    }

    for (int i = 0; i < K%50; i++)
    {
        ans[i] += 50+1;
        for (int j = 0; j < 50; j++)
        {
            ans[j]--;
        }
    }
    
    cout << 50 << endl;
    for (int i = 0; i < 50; i++)
    {
        cout << ans[i] << endl;
    }
    
    
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: usize,
        b: usize,
        t: usize
    }

    println!("{}", (t / a) * b);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <iostream>

int main()
{
	int A;

	std::cin >> A;

	switch (A) {
		case 3:
		case 5:
		case 7:
			std::cout << "YES" << std::endl;
			break;
		default:
			std::cout << "NO" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

void solve() {
  int N; cin >> N;
  map<char, ll> initial;
  rep(i,N) {
    string name; cin >> name;
    ++initial[name[0]];
  }
  
  string MARCH = "MARCH";
  ll ans = 0;
  for (int i=0; i<3; ++i) {
    char x = MARCH[i];
    for (int j=i+1; j<4; ++j) {
      char y = MARCH[j];
      for (int k=j+1; k<5; ++k) {
        char z = MARCH[k];
        ans += initial[x] * initial[y] * initial[z];
      }
    }
  }

  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int h, w;
    cin >> h >> w;
    int bcnt = 0;
    vector<vector<int>> grid(h, vector<int>(w, inf));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char sq;
            cin >> sq;
            if (sq == '#') {
                ++bcnt;
                grid[i][j] = -1;
            }
        }
    }
    queue<pair<int, int>> que;
    que.push({0, 0});
    grid[0][0] = 1;
    pair<int, int> d[] = {
        {1, 0},
        {-1, 0},
        {0, 1},
        {0, -1},
    };
    while (!que.empty()) {
        auto from = que.front();
        que.pop();

        for (const auto &e : d) {
            int toy = from.first + e.first;
            int tox = from.second + e.second;

            if (0 <= toy && toy < h && 0 <= tox && tox < w && grid[toy][tox] == inf) {
                grid[toy][tox] = grid[from.first][from.second] + 1;
                que.push({toy, tox});
            }
        }
    }
    
    if (grid[h - 1][w - 1] != inf)
        cout << (h * w - bcnt - grid[h - 1][w - 1]) << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int h,w,t[1024][1024];
string s[1024];
queue<P> q;

int main(void){
	int i,j,x,y,a,b,ans=0;
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> s[i];
		for(j=0; j<w; ++j){
			if(s[i][j]=='.'){
				q.push(P(i,j));
				s[i][j] = 0;
			}else{
				s[i][j] -= '0';
			}
		}
	}
	while(!q.empty()){
		a = q.front().first;
		b = q.front().second;
		q.pop();
		ans = max(ans,t[a][b]);
		for(i=-1; i<2; ++i){
			for(j=-1; j<2; ++j){
				x = a+i; y = b+j;
				if(!(0<=x && x<h && 0<=y && y<w)){
					continue;
				}else if(!(i||j)){
					continue;
				}else if(!s[x][y]){
					continue;
				}
				--s[x][y];
				if(!s[x][y]){
					q.push(P(x,y));
					t[x][y] = t[a][b]+1;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 2000009
#define MOD 1000000007
//#define endl '\n'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    //cout<<s<<endl;
   
    ll ans = 0;
    ll ans1=0;

    for (ll i = 0; i < s.size(); i++)
    {
        if(s[i]=='0'){
            ans++;
        }else{
            ans1++;
        }
    }
    cout << min(ans,ans1)*2 << endl;
    return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  cout << (n+1)/2 << endl;

  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
from collections import Counter


def solve(n, ddd):
    if ddd[0] != 0:
        return 0
    cnt = Counter(ddd)
    if cnt[0] != 1:
        return 0
    max_c = max(cnt)
    for i in range(max_c + 1):
        if i not in cnt:
            return 0

    MOD = 998244353
    ans = 1
    for i in range(max_c):
        prev = cnt[i]
        curr = cnt[i + 1]
        ans = ans * pow(prev, curr, MOD) % MOD
    return ans


n = int(input())
ddd = list(map(int, input().split()))

print(solve(n, ddd))


Measured memory_bytes: 19936
f=->n,m,a,b{a/m*n*~-n/2+(b-=m*y=(b+n*a%=m)/m
y>0?f[y,a,m,b%a]+y*=n+b/a:0)}
gets
$<.map{eval"p f[#{_1.split*?,}]"}

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

Measured memory_bytes: 256