akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define mod 1000000007

void helper(vector<vector<int>>& arr, int *val, int x, int pos, int n, int m, int cost, int &ans){
    if(pos >= n) return;
    for(int i = 0; i < m; ++i)
        val[i] += arr[pos][i+1];
    cost += arr[pos][0];
    if(x <= *min_element(val, val+m))
        ans = min(ans, cost);
    else helper(arr, val, x, pos+1, n, m, cost, ans);
    for(int i = 0; i < m; ++i)
        val[i] -= arr[pos][i+1];
    cost -= arr[pos][0];
    helper(arr, val, x, pos+1, n, m, cost, ans);
}

void solve(){

    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> arr (n, vector<int> (m, 0));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j <= m; ++j)
            cin >> arr[i][j];
    int ans = INT_MAX;
    int val[m];
    for(int i = 0; i < m; ++i)
        val[i] = 0;
    helper(arr, val, x, 0, n, m, 0, ans);

    if(ans == INT_MAX) cout << -1;
    else cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int t; cin >> t;
    //while(t--){
        solve();    
    //}
	return 0;
}
/*
int add(int a, int b){
    return a + b;
}
*/


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define db long double
using namespace std;
int n,k;
int tme[200009];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=k-1;i>=1;i--)
		tme[i]=tme[i*2]+1;
	db ans=0;
	for(int i=1;i<=n;i++)
		ans+=(db)1.0/(1<<tme[i]);
	printf("%.12lf",(double)(ans/n));
	return 0;
}

Measured memory_bytes: 640
H, W = [int(i) for i in input().split()]
maze = [list(input()) for _ in range(H)]
maze = [l for l in maze if "#" in l]
maze = list(zip(*maze))
maze = [l for l in maze if "#" in l]
maze = list(zip(*maze))
maze = ["".join(l) for l in maze]
print(*maze, sep="\n")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  ll cnt = X / D;
  if(cnt>K){
    cout << X - K * D << endl;
    return 0;
  }
  ll r = X % D;
  if ((K - cnt) % 2 == 0) cout << r << endl;
  else cout << min(abs(r+D), abs(r-D)) << endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
	ll n;
	cin >> n;
	vll a(n);
	vin(a);
	vll x(n, 0);
	rep(i, 0, n) x.at(0) += a.at(i) * (i % 2 == 0 ? 1 : -1);
	rep(i, 1, n) x.at(i) = a.at(i - 1) * 2 - x.at(i - 1);
	rep(i, 0, n) cout << x.at(i) << (i == n - 1 ? "" : " ");
	cout << endl;
}

Measured memory_bytes: 2944
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;



void main() {
    int n, m;
    scan(n, m);
    auto p = readln.split.to!(int[]);
    p[] -= 1;

    auto uf = UnionFind(n);

    foreach (i ; 0 .. m) {
        int xi, yi;
        scan(xi, yi);
        xi--, yi--;
        uf.merge(xi, yi);
    }

    auto c = new int[](n);
    foreach (i ; 0 .. n) {
        c[i] = uf.findRoot(i);
    }

    auto ok = new bool[int][](n);

    foreach (int i ; 0 .. n) {
        ok[c[i]][i] = 1;
    }

    debug {
        writeln(ok);
    }

    int ans;

    foreach (i ; 0 .. n) {
        if (p[i] in ok[c[i]]) {
            ans++;
        }
    }

    writeln(ans);
}



























struct UnionFind {
    private {
        int _size;
        int[] _parent;
    }

    this(int N) 
    in {
        assert(N > 0);
    }
    body {
        _size = N;
        _parent = new int[](_size);
        foreach (i ; 0 .. _size) {
            _parent[i] = i;
        }
    }

    int findRoot(int x)
    in {
        assert(0 <= x && x < _size);
    }
    body {
        if (_parent[x] != x) {
            _parent[x] = findRoot(_parent[x]);
        }

        return _parent[x];
    }

    bool same(int x, int y)
    in {
        assert(0 <= x && x < _size);
        assert(0 <= y && y < _size);
    }
    body {
        return findRoot(x) == findRoot(y);
    }

    void merge(int x, int y)
    in {
        assert(0 <= x && x < _size);
        assert(0 <= y && y < _size);
    }
    body {
        int u = findRoot(x);
        int v = findRoot(y);

        if (u == v) return;

        _parent[v] = u;
    }
}



































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 25788
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(int to0, int cost0){
        to = to0;
        cost = cost0;
    }
};

const int INF = INT_MAX / 2;

void solve(vector<vector<string> >& name, vector<vector<int> >& price, vector<string>& need, vector<vector<Edge> >& edges)
{
    int n = name.size();
    int q = need.size();

    vector<int> minPrice(q, INF);
    for(int i=0; i<q; ++i){
        for(int j=0; j<n; ++j){
            for(unsigned k=0; k<name[j].size(); ++k){
                if(name[j][k] == need[i] && price[j][k] < minPrice[i])
                    minPrice[i] = price[j][k];
            }
        }
    }
    vector<bitset<15> > buy(n, 0);
    for(int i=0; i<q; ++i){
        if(minPrice[i] == INF){
            cout << "impossible" << endl;
            return;
        }
        for(int j=0; j<n; ++j){
            for(unsigned k=0; k<name[j].size(); ++k){
                if(name[j][k] == need[i] && price[j][k] == minPrice[i])
                    buy[j][i] = true;
            }
        }
    }
    cout << accumulate(minPrice.begin(), minPrice.end(), 0) << ' ';

    vector<vector<int> > dp(n, vector<int>(1<<q, INF));
    multimap<int, pair<int, int> > m;
    dp[0][0] = 0;
    m.insert(make_pair(0, make_pair(0, 0)));
    for(;;){
        multimap<int, pair<int, int> >::iterator it = m.begin();
        int cost = it->first;
        int pos = it->second.first;
        bitset<15> bs(it->second.second);
        m.erase(it);
        if(cost > dp[pos][bs.to_ulong()])
            continue;
        if(pos == 0 && bs.count() == q){
            cout << cost << endl;
            return;
        }
        for(unsigned i=0; i<edges[pos].size(); ++i){
            int to = edges[pos][i].to;
            int cost1 = cost + edges[pos][i].cost;
            bitset<15> bs1 = bs | buy[to];
            if(cost1 < dp[to][bs1.to_ulong()]){
                dp[to][bs1.to_ulong()] = cost1;
                m.insert(make_pair(cost1, make_pair(to, bs1.to_ulong())));
            }
        }
    }
}

int main()
{
    for(;;){
        int n, q, m;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<string> > name(n+1);
        vector<vector<int> > price(n+1);
        for(int i=1; i<=n; ++i){
            int k;
            cin >> k;
            name[i].resize(k);
            price[i].resize(k);
            for(int j=0; j<k; ++j)
                cin >> name[i][j] >> price[i][j];
        }

        cin >> q;
        vector<string> need(q);
        for(int i=0; i<q; ++i)
            cin >> need[i];

        cin >> m;
        vector<vector<Edge> > edges(n+1);
        for(int i=0; i<m; ++i){
            int s, t, d;
            cin >> s >> t >> d;
            edges[s].push_back(Edge(t, d));
            edges[t].push_back(Edge(s, d));
        }

        solve(name, price, need, edges);
    }
}

Measured memory_bytes: 0
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
package main

import "fmt"

func factorial(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		// fact = fact * i
		fact = fact * i % 1000000007
	}
	return fact
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	switch {
	case n == m:
		x := factorial(n)
		fmt.Println(x * x * 2 % 1000000007)
	case n+1 == m || n == m+1:
		fmt.Println(factorial(n) * factorial(m) % 1000000007)
	default:
		fmt.Println(0)
	}
}


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

using namespace std;

int main() {
    int x;
    cin >> x;
    for (int i = 1; i <= 360; i++) {
        if (x * i % 360 == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
A.sort()
ans = 0
sumA = sum(A)
for i in range(N):
    sumA -= A[i]
    for j in range(i+1,N):
        if A[i] > A[j]:
            continue
        ans += (A[i] * (sumA % MOD)) %MOD
        break

print(ans % MOD)


Measured memory_bytes: 94068
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mathpi 3.14159265358979
using namespace std;
bitset<2000009> bits;
int main(){
	int n;
	ll sum=0;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(n==1){
		cout<<a[0]<<endl;
		return 0;
	}
	bits[0]=1;
	for(int i=0;i<n;i++){
		bits = bits | (bits<<a[i]);
	}
	for(int i=sum/2;i>0;i--){
		if(bits[i]==1){
			cout<<sum-i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int k = 0; k < W; k++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


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

int a[200010];
deque<int> v;
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)scanf("%d", &a[i]);
	for(int i = 0;i < n;i++){
		if(n % 2 == 1){
			if(i % 2 == 0)v.push_front(a[i]);
			else v.push_back(a[i]);
		}else{
			if(i % 2 == 0)v.push_back(a[i]);
			else v.push_front(a[i]);
		}
	}
	printf("%d", v[0]);
	for(int i = 1;i < n;i++){
		printf(" %d", v[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {
	static int n;
	static int h;
	static int w;

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

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		h = Integer.parseInt(str[0]);
		w = Integer.parseInt(str[1]);

		String matrix[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
			}
		}

		int max = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int dist[][] = new int[h][w];
				if (matrix[i][j].equals(".")) {
					dist = bfs(matrix, j, i);
				}
				for (int k = 0; k < h; k++) {
					for (int l = 0; l < w; l++) {
						max = Math.max(max, dist[k][l]);
					}
				}
			}
		}
		System.out.println(max);
	}

	static int[][] bfs(String matrix[][], int sx, int sy) {
		int dist[][] = new int[h][w];
		boolean used[][] = new boolean[h][w];

		Queue<Integer> qX = new ArrayDeque<>();
		Queue<Integer> qY = new ArrayDeque<>();
		qX.add(sx);
		qY.add(sy);
		used[sy][sx] = true;
		dist[sy][sx] = 0;

		while (!qX.isEmpty() && !qY.isEmpty()) {
			int x = qX.poll();
			int y = qY.poll();

			for (int i = 0; i < 4; i++) {
				int nx = x + dx[i];
				int ny = y + dy[i];

				if (nx >= 0 && nx < w && ny >= 0 && ny < h && matrix[ny][nx].equals(".")) {
					if (!used[ny][nx]) {
						used[ny][nx] = true;
						dist[ny][nx] = dist[y][x] + 1;
						qX.add(nx);
						qY.add(ny);
					}
				}
			}
		}
		return dist;
	}
}

Measured memory_bytes: 25516
fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(" ").map { it.toLong() }
    if (r - l >= 2100) {
        println(0)
        return
    }
    var ans = Long.MAX_VALUE
    for (i in l..r) {
        for (j in (i + 1)..r) {
            if (i * j % 2019 < ans) {
                ans = i * j % 2019
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 38004
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e6+1;
string s;
int dp[A][2];
int solve(int ind, bool rem)
{
	if (ind == (int)s.size())
		return rem;
	if (~dp[ind][rem])
		return dp[ind][rem];

	int ret = 2e9;
	if (s[ind] != '9') ret = solve(ind + 1, 1) + rem + 1 + (s[ind] - '0');

	ret = min(ret, solve(ind + 1, 0) + rem + (s[ind] - '0'));

	ret = min(ret, solve(ind + 1, 0) + (rem ? 0 : 1) + (10 - (s[ind] - '0')));

	ret = min(ret, solve(ind + 1, 1) + (rem ? 0 : 1) + (9 - (s[ind] - '0')));

	return dp[ind][rem] = ret;
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> s;
	memset(dp, -1, sizeof dp);
	cout << solve(0, 0);
	return 0;
}


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

int main(){
 int n;
  cin >>n;
  int g=n+1;
 int a[g],b[g],c[g],va[g],vb[g],vc[g];
  rep(i,n){
  cin>>a[i+1]>>b[i+1]>>c[i+1];
  }
  va[1]=a[1];vb[1]=b[1];vc[1]=c[1];
  for(int i=2;i<=n;i++){
     va[i]=max(vb[i-1]+a[i],vc[i-1]+a[i]);
   	 vb[i]=max(va[i-1]+b[i],vc[i-1]+b[i]); 
     vc[i]=max(va[i-1]+c[i],vb[i-1]+c[i]);
  }
  int ans;
  ans=max(max(va[n],vb[n]),vc[n]);
  cout <<ans<<endl;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  for(int i = 1 ; i <= h ; i++){
    bool flag = false;
    for(int j = 0 ; j < w ; j++){
      string s;
      cin >> s;
      if(s == "snuke"){
        char c = 'A' + j;
        cout << c << i << endl;
        flag = true;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int solve() {
  ll h,w,n;
  cin >> h >> w >> n;
  vector<ll> a(n);
  vector<vector<ll> > res(h, vector<ll> (w, 0));
  for(ll i = 0;i < n;i++){
    cin >> a[i];
  }
  ll x = 0;
  ll y = 0;
  ll cnt = 0;
  for(ll i = 0;i < n; i++){
    while(a[i] > cnt){
      res[y][x] = i + 1;
      if(y % 2 == 0){
        x++;
      }else{
        x--;
      }
      if(x == w || x == -1){
        y = min(h - 1,y + 1);
        if(x == w){
          x--;
        }else{
          x++;
        }
      }
      cnt++;
    }
    cnt = 0;
  }
  for(ll i = 0;i < h; i++){
    for(ll j = 0;j < w; j++){
      cout << res[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


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


Measured memory_bytes: 512
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int n;string s;cin>>n>>s;vector<int>bs(n+1),ws(n+1);for(int i=1;i<=n;i++)bs[i]=bs[i-1]+(s[i-1]=='#');for(int i=n-1;i>=0;i--)ws[i]=ws[i+1]+(s[i]=='.');int m=INF;for(int i=0;i<=n;i++)updmin(m,bs[i]+ws[i]);cout<<m<<endl;}


Measured memory_bytes: 2180
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a[3];
    repi(i,3,0){
        cin >> a[i];
    }
    int index[3] = {0,1,2};
    int ans = INF;
    do{
        int tmp = a[index[0]] + a[index[1]];
        ans = min(ans,tmp);
    }while(next_permutation(index,index + 3));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
        e<-getLine
        let 
             (a:b:w:[])=map read (words e)::[Int]
        mapM_ putStrLn $ map show $ sort $ nub $ filter (<= b ) $ filter (>= a ) $ [a..(a+w-1)]++[b,(b-1)..(b-w+1)]

Measured memory_bytes: 764
// https://atcoder.jp/contests/abc103/tasks/abc103_a

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a[3];

  cin >> a[0] >> a[1] >> a[2];

  sort(a, a + 3);

  cout << a[2] - a[0] << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  string s;cin >> s;
  stack<char> st;
  string t;
  rep(i,N){
    if(s[i] == '(')st.push('(');
    else if(st.size()!=0)st.pop();
    else t.push_back('(');
  }
  t += s;
  rep(i,st.size()){
    t.push_back(')');
  }
  cout << t << endl;
  return 0;
}


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

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

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

  int ans = 0;
  for (int i = 0; i < 3; ++i) if (s[i] == t[i]) ++ans;

  cout << ans << endl;

  return (0);
}


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

int main()
{
    int N, i, cnt=0;
    cin >> N;
    int P[N];
    for(i=0; i<N; i++)
    {
        cin >> P[i];
    }
    int curmin=1e9;
    rep(i, N)
    {
        curmin=min(curmin, P[i]);
        if(curmin==P[i])
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int W;
	int a,b;

	scanf("%d %d %d",&W,&a,&b);

	if(a>b){
		swap(a,b);
	}
	if(a+W<b){
		printf("%d\n",b-a-W);
	}else{
		printf("0\n");
	}

	return 0;
}


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

int main(){
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  
  if(abs(b-a)<=(v-w)*t){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>

using namespace std;

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

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

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

  int w;
  cin >> w;

  string ans = "";
  for (int i = 0; i < s.size(); ++i) {
    if (i % w == 0)
      ans.push_back(s[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
class Puzzle
  attr_accessor :s, :cou, :direction
  def initialize(s, direction, cou=-1)
    @s = s
    @cou = cou
    @direction = direction
  end

  def calc
    nums = @s.dup
    @s.each_with_index do |x, i_x|
      @s[i_x..-1].each_with_index do |y, i_y|
        nums[i_x + i_y] -= 1 if y > x
      end
    end
    number = 0
    nums.each_with_index do |x, i_x|
      factorial = (nums.size - 1 - i_x).downto(1).inject(:*)
      number += factorial * x if factorial != nil
    end
    return number
  end

  def zero
    return @s.index(0)
  end
end

class Dic
  attr_reader :visit, :cou
  def initialize(num)
    @visit = Array.new(num, 1)
    @cou = Array.new(num, 0)
  end
  def visited?(id, direction)
    return @visit[id] != 1 && @visit[id] % direction == 0
  end
  def visit(puzzle)
    id = puzzle.calc
    direction = puzzle.direction
    cou = puzzle.cou
    @visit[id] *= direction
    @cou[id] += cou
  end

  def get(puzzle)
    return cou[puzzle.calc]
  end
end

move = [[1, 3],
        [0, 2, 4],
        [1, 5],
        [0, 4, 6],
        [1, 3, 5, 7],
        [2, 4, 8],
        [3, 7],
        [4, 6, 8],
        [5, 7]]

col = [1, 2, 3, 4, 5, 6, 7, 8, 0]

f = 2
b = 3

# main
init_s = []
3.times do
  init_s.concat(gets.chomp.split.map(&:to_i))
end

queue = []
init = Puzzle.new(init_s, f, 0)
goal = Puzzle.new(col, b, 0)
queue << init
queue << goal

dict = Dic.new(9.downto(1).inject(:*))
dict.visit(init)
dict.visit(goal)

while queue.size > 0 do
  puzzle = queue.shift
  id = puzzle.calc
  if dict.visited?(id, f) && dict.visited?(id, b) then
    puts dict.cou[id]
    break
  end

  zero = puzzle.zero
  swap = move[zero]

  swap.each{|swap_pos|
    new = Puzzle.new(puzzle.s.dup,puzzle.direction,puzzle.cou+1)
    new.s[zero], new.s[swap_pos] = new.s[swap_pos], new.s[zero]
    next if dict.visited?(new.calc, new.direction)
    queue << new
    dict.visit(new)
  }
end


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


int main() {
    int cnt[4] = {};
    for (int i = 0; i < 3; ++i) {
        int a, b;
        cin >> a >> b; cnt[a-1]++; cnt[b-1]++;
    }
    if (*max_element(cnt, cnt+4) == 3) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
inline li read(){
    li x = 0,y = 0,c = gc;
    while(!isdigit(c)) y = c,c = gc;
    while(isdigit(c)) x = x * 10 + c - '0',c = gc;
    return y == '-' ? -x : x;
}
inline void print(li q){
    if(q < 0) pc('-'),q = -q;
    if(q >= 10) print(q / 10);
    pc(q % 10 + '0');
}
inline void file(){
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
li s1 = 19260817,s2 = 23333333,s3 = 998244353,srd;
inline li rd(){
	return srd = (srd * s1 + s2 + rand()) % s3;
}
int n,m,a[1000010],b[1000010],d,mx;
int t1[5000010],t2[5000010],c[5000010];
#define ls q << 1
#define rs q << 1 | 1
#define ln ls,l,mid
#define rn rs,mid + 1,r
#define md int mid = l + r >> 1
inline void ps(int q){
	t1[ls] += c[q];c[ls] += c[q];
	t1[rs] += c[q];c[rs] += c[q];
	c[q] = 0;
}
inline void build(int q,int l,int r){
	t1[q] = 0;t2[q] = r - l + 1;
	if(l == r) return;
	md;
	build(ln);build(rn);
}
inline void xg(int q,int l,int r,int al,int ar,int x){
	assert(al <= ar);
	//if(q == 1) cerr<<al<<" "<<ar<<"*"<<x<<endl;
	if(l >= al && r <= ar){
		t1[q] += x;
		c[q] += x;
		//cerr<<q<<"&&"<<l<<" "<<r<<":"<<t1[q]<<" "<<t2[q]<<endl;
		return;
	}
	ps(q);
	md;
	if(mid >= al) xg(ln,al,ar,x);
	if(mid < ar) xg(rn,al,ar,x);
	t1[q] = min(t1[ls],t1[rs]);t2[q] = 0;
	if(t1[q] == t1[ls]) t2[q] += t2[ls];
	if(t1[q] == t1[rs]) t2[q] += t2[rs];
	//cerr<<q<<"&&"<<l<<" "<<r<<":"<<t1[q]<<" "<<t2[q]<<endl;
}
inline int cx(int q,int l,int r,int al,int ar){
	assert(al <= ar);
	//if(q == 1) cerr<<al<<"&"<<ar<<endl;
	if(l >= al && r <= ar) return t1[q] ? 0 : t2[q];
	ps(q);
	md;
	int as = 0;
	if(mid >= al) as = cx(ln,al,ar);
	if(mid < ar) as += cx(rn,al,ar);
	//cerr<<q<<"()"<<l<<" "<<r<<" "<<t1[q]<<" "<<t2[q]<<":"<<as<<endl;
	return as;
}
int main(){
	srand(time(0));rd();
    //file();
	int i,j,u,v;
	n = read();m = read();
	mx = n + n + m + m;
	build(1,1,mx);
	for(i = 1;i <= n;++i){
		a[i] = read();
		++b[a[i] + n + m];
		xg(1,1,mx,a[i] - b[a[i] + n + m] + 1 + n + m,a[i] - b[a[i] + n + m] + 1 + n + m,1);
		//cerr<<a[i] - b[a[i]] + 1 + m<<"*"<<endl;
	} 
	for(i = 1;i <= m;++i){
		u = read();v = read();
		if(u){
			v -= d;
			if(a[u] + d >= 1 && a[u] + d <= n) xg(1,1,mx,a[u] - b[a[u] + n + m] + 1 + n + m,a[u] - b[a[u] + n + m] + 1 + n + m,-1);
			--b[a[u] + n + m];a[u] = v;++b[a[u] + n + m];
			if(a[u] + d >= 1 && a[u] + d <= n) xg(1,1,mx,a[u] - b[a[u] + n + m] + 1 + n + m,a[u] - b[a[u] + n + m] + 1 + n + m,1);
		}
		else{
			d += v;
			if(v == 1){
				if(b[n + 1 - d + n + m]) xg(1,1,mx,n + 1 - d + n + m - b[n + 1 - d + n + m] + 1,n + 1 - d + n + m,-1);
				if(b[1 - d + n + m]) xg(1,1,mx,1 - d + n + m - b[1 - d + n + m] + 1,1 - d + n + m,1);
			}
			else{
				if(b[n - d + n + m]) xg(1,1,mx,n - d + n + m - b[n - d + n + m] + 1,n - d + n + m,1);
				if(b[0 - d + n + m]) xg(1,1,mx,0 - d + n + m - b[0 - d + n + m] + 1,0 - d + n + m,-1);
			}
		} 
		//cerr<<m + 1 - d<<"()"<<m + n - d<<endl;
		print(cx(1,1,mx,n + m + 1 - d,n + m + n - d));pc('\n');
	}
    return 0;
}


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

#define MOD 1000000007

int main()
{
    ll N, K; cin >> N >> K;

    vector<ll> fact(N+1);
    vector<ll> finv(fact.size());
    vector<ll> inv(fact.size());
    
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = 0; inv[1] = 1;
    for (int i = 2; i < fact.size(); i++) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

    auto C = [&](ll n, ll r) {
        return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
    };
    auto H = [&](ll n, ll r) {
        return C(n+r-1, r);
    };

    ll ans = 0;

    for (int i = 0; i <= min(N-1, K); i++) {
        ans = (ans + C(N, i) * H(N-i, i) % MOD) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main() {
	char a[5] = "MMYY";
	char b[5] = "YYMM";
	char c[5] = "NA";
	char d[10] = "AMBIGUOUS";
	int in;
	int l, r;
	cin >> in;
	l = in / 100;
	r = in % 100;
	if (1 <= l&& l<= 12) {
		if(1<=r&&r<=12) cout << d;
		else cout << a;
	}
	else {
		if (1 <= r&&r <= 12) cout << b;
		else cout << c;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int a[3][105];
int digui(int x,int y)
{
	if(x==1&&y==1)
		return a[1][1];
	else if(x==1)
		return digui(1,y-1)+a[1][y];
	else if(y==1)
		return digui(x-1,1)+a[x][1];
	else
		return max(digui(x-1,y),digui(x,y-1))+a[x][y];
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;++i)
		for(int j=1;j<=n;++j)
			scanf("%d",a[i]+j);
	printf("%d\n",digui(2,n));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 1e6;
ll po(int,int);
bool dp[N+5]={0};
void solve(){
    int n;cin>>n;
    int a[n];
    map<int,int> m;
    FOR(i,0,n){
        cin>>a[i];
        m[a[i]]++;
    }
    sort(a,a+n);
    FOR(i,0,n){
        for(int j=(m[a[i]]==1)?2*a[i]:a[i];j<=a[n-1];j+=a[i]){
            dp[j]=1;
        }
    }
    int ans=0;
    FOR(i,0,n){
        if(!dp[a[i]]) ans++;
    }
    cout<<ans;
    
} 





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 13884
#include <bits/stdc++.h>
using namespace std;
string S;
int sums,sumt;
int main()
{
    cin>>S;
    for(int i=0;i<S.size();i++)
    {
        if(S[i] == 'S') 
		  sums++;
        if((sums)&&(S[i]=='T'))
        {
            sums--;
              sumt+=2;
        }
    }
    cout<<S.size()-sumt<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
using namespace std;

int main()
{ 

fast;
	ll n,w;
	cin>>n>>w;

	ll wt[n],val[n];
	for(ll i=0;i<n;i++)
		cin>>wt[i]>>val[i];

	ll dp[n+1][100001];
	
	for(ll i=0;i<n+1;i++)
	for(ll j=0;j<100001;j++)
	dp[i][j]=inf;

		for(ll i=0;i<n+1;i++)
			dp[i][0]=0;
		
	for(ll i=1;i<n+1;i++)
	{
		for(ll j=1;j<100001;j++)
		{
		    dp[i][j]=dp[i-1][j];
			if(j>=val[i-1])
				dp[i][j]=min(dp[i][j],dp[i-1][j-val[i-1]]+wt[i-1]);
		}
	}
 for(ll i=100000;i>-1;i--)
 {
     if(dp[n][i]<=w)
     {
         cout<<i<<endl;
         return 0;
     }
 }
}


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

int main()
{
    string Class[11]={"light fly","fly","bantam","feather","light",
                        "light welter","welter","light middle","middle","light heavy","heavy"};
    double weight;

    while(cin>>weight,!cin.eof()){
        if(weight<=48.00){
            cout<<Class[0]<<endl;
        }
        else if(weight<=51.00 && weight>48.00){
            cout<<Class[1]<<endl;
        }
        else if(weight<=54.00 && weight>51.00){
            cout<<Class[2]<<endl;
        }
        else if(weight<=57.00 && weight>54.00){
            cout<<Class[3]<<endl;
        }
        else if(weight<=60.00 && weight>57.00){
            cout<<Class[4]<<endl;
        }
        else if(weight<=64.00 && weight>60.00){
            cout<<Class[5]<<endl;
        }
        else if(weight<=69.00 && weight>64.00){
            cout<<Class[6]<<endl;
        }
        else if(weight<=75.00 && weight>69.00){
            cout<<Class[7]<<endl;
        }
        else if(weight<=81.00 && weight>75.00){
            cout<<Class[8]<<endl;
        }
        else if(weight<=91.00 && weight>81.00){
            cout<<Class[9]<<endl;
        }
        else if(weight>91.00){
            cout<<Class[10]<<endl;
        }
    }
    return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


template< typename Monoid >
struct SegmentTree {
    using F = function< Monoid(Monoid, Monoid) >;

    int sz;
    vector< Monoid > seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while (sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for (int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while (k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = f(L, seg[a++]);
            if (b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }
};

int main() {
    int N; cin >> N;
    vi h(N);
    rep(i, N) {
        cin >> h[i]; h[i]--;
    }
    vll a(N);
    rep(i, N) cin >> a[i];

    SegmentTree<ll> seg(N + 1, [](ll a, ll b) { return max(a, b); }, -1);
    ll ans = 0;
    ll dp, tmp;
    rep(i, N) {
        tmp = max(seg.query(0, h[i]), 0LL);
        dp = tmp + a[i];
        chmax(ans, dp);
        seg.update(h[i], dp);
    }

    cout << ans << endl;

}

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int n;
vi a;

LL solve(int num) {
	LL res = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (sum * num <= 0) {
			res += abs(sum - num);
			sum = num;
		}
		num *= -1;
	}
	return res;
}

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

	cin >> n;
	a.resize(n);

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

	cout << min(solve(1), solve(-1)) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	
	ll n;
	cin >> n;
	unordered_map<ll, ll> mp;
	for(ll i = 0 ;i < n; i++){
		ll a;
		cin >> a;
		mp[a]++;
		if(mp[a] == 2){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 8520
# coding: utf-8
l,r = map(int,input().split())
m = l*r%2019
if r-l >= 2019:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            m = min(m,i*j%2019)
    print(m)

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

int bubbleSort(vector<int> &A, int N) {
    bool flag = 1;
    int count = 0;
    while (flag) {
        flag = 0;
        for (int j = N -1; j > 0; j--) {
            if (A.at(j) < A.at(j-1)) {
                int v = A.at(j);
                A.at(j) = A.at(j-1);
                A.at(j-1) = v;
                count++;
                flag = 1;
            }
        }
    }
    return count;
}
int main() {
    int n;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data.at(i);
    }
    int a = bubbleSort(data, n);
    for (int i = 0; i < n; i++) {
        if (i == n-1) {
            cout << data.at(i) << endl;
        } else {
            cout << data.at(i) << " " ;
        }
    }
    cout << a << endl;     
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

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

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

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


#define INF 2e64 //初期化注意
#define MAX_V 100000 //頂点数の最大値

struct edge {
	int to;
	ll cost;
	//edge e ={to, cost}
};

// <最短距離, 頂点の番号>
using P = pair<int, ll>;

int V;// 頂点の数
vector<edge> G[MAX_V];
ll d[MAX_V];
void dijkstra(int s) {
	//sからiへの最短距離をd[i]に保存 i=e.to
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;//初期位置へのコストは0

	que.push(P(0, s));
	//queはmake_pair(cost,to)?

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;//v=e.to	from s to v
		//すでにこの経路よりいい経路が見つかっているなら無視
		if (d[v] < p.first) continue;
		

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			// i 番目の v と v'を結ぶ辺　G=<e.to, e.cost>
			//e.to=v'
	                //e.cost means v to v' costs e.cost
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				//from s to v'> from s to v + from v to v'
				//vを経由したほうがコストが低いなら経由する
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
void solve() {
	cin >> V;
	int E=V-1;//辺の数
	for (int i = 0; i < E; ++i) {
		int a, b, c;
		cin >> a >> b>>c ;
		a--; b--;
		//the route a to b costs c
		edge e = { b, c };
		G[a].push_back(e);
        e={a,c};
        G[b].push_back(e);
		//有向グラフの場合であり、無向グラフなら e{a,c}も必要
	}
	dijkstra(0);
	//dijkstra(int s); nからの最短距離を計算
	//d[i]はsからiまでの最短距離が保存される the path from s to i costs d[i]
    
    rep(i,V){
        if(d[i]%2==0){
            cout<<0<<endl;
        }else{
            cout<<1<<endl;
        }
    }
}


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

Measured memory_bytes: 9600
import sys
from heapq import heappush, heappop

class UFSet:
    def __init__(self, n):
        self.fa = [i for i in range(n)]
        
    def find(self, v):
        if v != self.fa[v]:
            self.fa[v] = self.find(self.fa[v])
        return self.fa[v]
    
    def union(self, a, b):
        pa = self.find(a)
        pb = self.find(b)
        self.fa[pa] = pb
        

def kruscal(Edges, V):
    ufset = UFSet(V)
    ret = 0
    
    for w, a, b in Edges:
        pa, pb = ufset.find(a), ufset.find(b)
        if pa == pb:
            continue
        else:
            ret += w
            ufset.union(pa, pb)
    
    return ret
            
    
    
if __name__ == '__main__':
    line = sys.stdin.readline()
    V, E = line.split()
    V, E = int(V), int(E)
    
    Es = []
    
    for i in range(E):
        line = sys.stdin.readline()
        a, b, w = line.split()
        a, b, w = int(a), int(b), int(w)
        Es.append((w, a, b))
    
    Es.sort()
        
        
    sys.stdout.write(str(kruscal(Es, V)) + '\n')
        

Measured memory_bytes: 23416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
int main(){
    int n; cin >> n;
    ll ans=0;
    rep(i,n){
        int now=i+1;
        if(now%3==0 || now%5==0) continue;
        ans+=now;
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3624
gets 
nums = gets.split.map(&:to_i)
(1..(nums.size - 1)).each{|index|
    if nums[index] > nums[index - 1]
        nums[index] -= 1
    end
}
gaps = nums.drop(1).zip(nums).map{|r, l| r - l}
puts gaps.all?{|it| it >= 0}  ? 'Yes' : 'No'

Measured memory_bytes: 15876
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, 0, N) {
        cin >> a[i];
    }

    const ll inf = 1LL << 60;
    auto dp = make_v(N, N, inf);
    function<ll(int, int, int)> rec = [&](int l, int r, int t) {
        if (l > r) return 0LL;
        if (dp[l][r] != inf) return dp[l][r];
        ll lv = rec(l + 1, r, !t) + (2 * t - 1) * a[l];
        ll rv = rec(l, r - 1, !t) + (2 * t - 1) * a[r];
        ll res = (t ? max(lv, rv) : min(lv, rv));
        return dp[l][r] = res;
    };

    cout << rec(0, N - 1, 1) << endl;

    return 0;
}


Measured memory_bytes: 71040
H, W, K = map(int, input().split())
s = [0]*H
a = [[0]*W for _ in range(H)]
for i in range(H):
    s[i] = input()
index = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            index += 1
            a[i][j] = index
            for k in range(j+1):
                if a[i][k] == 0:
                    a[i][k] = index
        elif j == W-1:
            if a[i][0] != 0:
                for k in range(j+1):
                    if a[i][k] == 0:
                        a[i][k] = index
for i in range(H-1):
    if a[i][0] == 0 and a[i+1][0] != 0:
        a[i] = a[i+1]
for i in reversed(range(H-1)):
    if a[i][0] == 0 and a[i+1][0] != 0:
        a[i] = a[i+1]
for i in range(1, H):
    if a[i][0] == 0 and a[i-1][0] != 0:
        a[i] = a[i-1]
for i in reversed(range(1, H)):
    if a[i][0] == 0 and a[i-1][0] != 0:
        a[i] = a[i-1]
for i in range(H):
    print(' '.join(map(str, a[i])))

Measured memory_bytes: 7244
N, P = map(int, input().split())
As = list(map(int, input().split()))
nE = 0
nO = 0
for A in As:
  if A%2 == 0:
    nE += 1
  else:
    nO += 1
#print(P, nE, nO)
r = 0
# \sum_{2k<=nO}C_nO_2k
for k in range(0 if P == 0 else 1, nO+1, 2):
  c = 1
  for i in range(1, k+1):
    c = c*(nO+1-i)//i
  r += c
r = r*2**nE
print(r)


Measured memory_bytes: 3064
from collections import deque

S = deque(input())
Q = int(input())

rev = False
for i in range(Q):
	query = input().split()
	if query[0] == '1':
		rev = not rev
	else:
		if (query[1] == '1' and rev == False) \
		or (query[1] == '2' and rev == True):
			S.appendleft(query[2])
		else:
			S.append(query[2])

if rev:
	S.reverse()

print("".join(S))


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

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)
 ll solve(ll n){
        ll ans=0;
        ll div=10;
        while(div<=n){
            ans+=n/div;
            div*=5;
        }
        return ans;
    }
long long INF = 1LL<<60;
int main(){
    ll n;
    cin>>n;
    if(n%2){
        cout<<0<<endl;
    }
    else{
       cout<<solve(n)<<endl;
    }
    return 0;
}




Measured memory_bytes: 256