akhauriyash/Code-Regression huggingface dataset:
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const plus = S.filter(n=>n==="+").length;
    const minus = S.length - plus;
    
    console.log(plus - minus);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n; n *= 2;
    ld ans = 3.14159265358 * n;
    cout << setpre(6) << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/


Measured memory_bytes: 3804
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N, K;
int D[2001];
int E[4001], ne[4001], he[2001];
void dfs(int v, int d) {
	D[v] = d;
	for (int to = he[v]; to; to = ne[to]) {
		if (D[E[to]] < 0) dfs(E[to], d + 1);
	}
}

int dfs2(int v, int prev, int d) {
	if (d > K / 2) return 0;
	int ret = 1;
	for (int to = he[v]; to; to = ne[to]) {
		if (E[to] != prev) ret += dfs2(E[to], v, d + 1);
	}
	return ret;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	N = getint();
	K = getint();
	int tmp = 1;
	int jisuu[2001] = {};
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[tmp] = b;
		ne[tmp] = he[a];
		he[a] = tmp++;
		E[tmp] = a;
		ne[tmp] = he[b];
		he[b] = tmp++;
		jisuu[a]++;
		jisuu[b]++;
	}

	if (K == 1) {
		printf("%d\n", N - 2);
		return 0;
	}

	rep1(j, N) D[j] = -1;
	dfs(1, 0);
	int saidai = 0;
	int doko, doko2;
	rep1(i, N) if (saidai < D[i]) {
		saidai = D[i];
		doko = i;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko, 0);
	saidai = 0;
	bool muri[2001] = {};
	rep1(i, N) {
		if (saidai < D[i]) {
			saidai = D[i];
			doko2 = i;
		}
		if (D[i] < K / 2) {
			muri[i] = 1;
		}
	}
	if (saidai <= K) {
		printf("0\n");
		return 0;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko2, 0);
	rep1(i, N) {
		if (D[i] < K / 2) muri[i] = 1;
		if (jisuu[i] == 1) muri[i] = 1;
	}

	if (K % 2 == 0) {
		int kotae = N;
		rep1(i, N) {
			if (!muri[i]) {
				int kazu = dfs2(i, -1, 0);
				kotae = min(kotae, N - kazu);
			}
		}
		printf("%d", kotae);
	}
	else {
		int kotae = N;
		rep1(k, N - 1) {
			int i = E[k * 2];
			int j = E[k * 2 - 1];
			if (!muri[i] && !muri[j]) {
				int kazu = dfs2(i, j, 0) + dfs2(j, i, 0);
				kotae = min(kotae, N - kazu);
			}
		}
		printf("%d", kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> s(n);
    REP(i,n) cin >> s[i];
    bool T = true;
    REP(i,n) if(s[i]%10 != 0) T=false;
    if(T) { 
        cout << 0 << std::endl;
        return 0;
    }
    ll sum = 0;
    REP(i,n) sum+=s[i];
    if (sum%10!=0) {
        cout << sum << std::endl;
    } 
    else {
        ll Max = 0;
        REP(i,n) {
            ll ans = sum-s[i];
            if (ans%10==0) continue;
            Max = max(ans, Max);
        }
        cout << Max << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
int N; cin >> N;
vector<int> a(N+1), b(N), c(N-1);
rep(i, N) cin >> a[i];
rep(i, N) cin >> b[i];
for(int i=0; i<N-1; i++) cin >> c[i];
int sum=0;
rep(i, N) {
  if(a[i+1]-a[i]==1) sum+=b[a[i]-1]+c[a[i]-1];
  else sum+=b[a[i]-1];
}
cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
xyd = [list(input().split()) for i in range(n)]
xmax,ymax = [-10**9,-10**9,-10**9],[-10**9,-10**9,-10**9]
xmin,ymin = [10**9,10**9,10**9],[10**9,10**9,10**9]
#xmax: max(x1-t,x2,x3+t)
#xmin: min(x1+t,x2,x3-t)
#ymax: max(y1-t,y2,y3+t)
#ymin: min(y1+t,y2,y3-t)
def chp(ls,a,flg1,i):
  if flg1:
    ls[i] = max(ls[i],a)
  else:
    ls[i] = min(ls[i],a)
def area(t):
  x = max(xmax[0]-t,xmax[1],xmax[2]+t)-min(xmin[0]+t,xmin[1],xmin[2]-t)
  y = max(ymax[0]-t,ymax[1],ymax[2]+t)-min(ymin[0]+t,ymin[1],ymin[2]-t)
  return x*y
for x,y,d in xyd:
  x,y = int(x),int(y)
  if d in ("L","R"):
    chp(ymax,y,1,1)
    chp(ymin,y,0,1)
    if d == "R":
      chp(xmin,x,0,0)
      chp(xmax,x,1,2)
    if d == "L":
      chp(xmin,x,0,2)
      chp(xmax,x,1,0)
  elif d in ("U","D"):
    chp(xmax,x,1,1)
    chp(xmin,x,0,1)
    if d == "U":
      chp(ymax,y,1,2)
      chp(ymin,y,0,0)
    if d == "D":
      chp(ymin,y,0,2)
      chp(ymax,y,1,0)

event = [0]
for ls in xmax,ymax:
  event.append(ls[0]-ls[1])
  event.append((ls[0]-ls[2])/2)
  event.append(ls[1]-ls[2])
for ls in xmin,ymin:
  event.append(ls[1]-ls[0])
  event.append((ls[2]-ls[0])/2)
  event.append(ls[2]-ls[1])
ans = 10**18

for i in event:
  if i>=0:
    for j in range(-10,10):
      if i+j*0.5 >= 0:
        ans = min(ans,area(i+j*0.5))
print(ans)

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

static const int N = 1000;

void trace(int A[], int n){
  for ( int i = 1; i <= n; i++ ){
    if ( i >1 ) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

main(){
  int n;
  int A[N+1];
  cin >> n;
  for ( int i = 1; i <= n; i++ ) cin >> A[i];
  
  trace(A, n);
  for ( int j = 2; j <= n; j++ ){
    int key = A[j];
    int i = j - 1;
    while( i > 0 && A[i] > key ){
      A[i+1] = A[i];
      i--;
    }
    A[i+1] = key;

    trace(A, n);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (auto &it : v)
		cin >> it;
	sort(all(v));
	ll sum = 0;
	for (int i = 0; i < k; i++)
		sum += v[i];
	cout << sum << endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, m, a, b;

	cin >> n >> m;

	vector<vector<ll>> v(100001);
	priority_queue<ll> q[100001];


	REP(i, n) {
		cin >> a >> b;
		q[a].push(b);
	}

	REP(i, 100001) {
		q[i].push(0);
	}

	ll now = 0;
	ll cnt = 0;
	ll ans = 0;

	vector<bool> used(n + 1, false);

	priority_queue<pair<ll, ll>> qq;

	ll x;
	pair<ll, ll> p;

	while (cnt < m) {
		x = q[cnt + 1].top();
		q[cnt + 1].pop();
		qq.push(make_pair(x, cnt + 1));
		p = qq.top();
		qq.pop();
		ans += p.first;
		x = q[p.second].top();
		q[p.second].pop();
		qq.push(make_pair(x, p.second));
		cnt++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 12024
/*
 * Author : Sadi
 * Tue 21/07/2020
 * 17:57:56.76
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    // map<int, int> m;
    vector<int> v(n + 1, 0);
    for(int i = 1; i < n; ++i) {
        int a;
        cin >> a;
        // m[a]++;
        v[a]++;
    }
    for(int i = 1; i <= n; ++i) {
        cout << v[i] << '\n';
    }
    return 0;
}


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

int main() {
  int A, B, a, b, c, d, e, t, k = 0;
  cin >> A >> B;
  for (int i = A; i < B + 1; i++) {
    e = i % 10;
    t = i / 10;
    d = t % 10;
    t /= 10;
    c = t % 10;
    t /= 10;
    b = t % 10;
    t /= 10;
    a = t;
    
    if (a == e && b == d) { k++;}
  }
  cout << k << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);

	public static void main(String[] args) {
			long a=sc.nextLong();
			long b=sc.nextLong();
			long c=sc.nextLong();
			
			if((a*b*c)%2==0) {
				p(0);
			}else {
				long v=Math.max(a, Math.max(c, b));
				long g[]= {a,b,c};
				for(int i=0;i<3;i++) {
					if(g[i]==v) {
						g[i]=1;
						break;
					}
				}
				long ans=1;
				for(int i=0;i<3;i++) {
					ans*=g[i];
				}
				p(ans);
			}
			
			
	}
	

	
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    string ans, pre;
    for(char c : s){
        if(c == '('){
            cnt++;
            ans += '(';
        }else{
            cnt--;
            ans += ')';
            if(cnt < 0){
                cnt++;
                pre += '(';
            }
        }
    }
    while(cnt--){
        ans += ')';
    }
    cout << pre + ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,a[200010],b[201000];
ll fac[10100],ret;
ll dp[4010][4010];
int cur[4010][4010];
int main() {
	scanf("%d",&n);
	fac[0]=1;
	rep(i,1,8010) {
		fac[i]=fac[i-1]*i%mod;
	}
	rep(i,0,n) {
		scanf("%d%d",a+i,b+i);
		dp[2001-a[i]][2001-b[i]]++;
		cur[2001+a[i]][2001+b[i]]++;
		ret=(ret-fac[2*(a[i]+b[i])]*powmod(fac[2*a[i]]*fac[2*b[i]],mod-2))%mod;
	}
	rep(i,1,4002) rep(j,1,4002) {
		dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
		ret=(ret+dp[i][j]*cur[i][j])%mod;
	}
	ret=ret*powmod(2,mod-2)%mod;
	if (ret<0) ret+=mod;
	printf("%lld\n",ret);
}


Measured memory_bytes: 150528
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;




//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        h: [usize;n],
        ab:[(Usize1,Usize1);m],
    }

    let mut v = vec![Vec::new();n];
    for x in ab {
        v[x.0].push(x.1);
        v[x.1].push(x.0);
    }

    let mut ans = 0;
    for i in 0..n {
        if v[i].iter().all(|&j|{h[i] > h[j]}) {
            ans += 1;
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 12208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<string, int> mp;
    bool ok = true;
    V<string> a(n);
    cin >> a;
    rep(i, n) {
        if(mp[a[i]] > 0) ok = false;
        if(i > 0 && a[i - 1].back() != a[i][0]) ok = false;
        mp[a[i]]++;
    }
    if(ok) Yes(); else No();
}

Measured memory_bytes: 3660
//Coded By Visnunathan

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.lang.*;

public class Main {
    static int[] arr;
    static int n,k;
    public static void main(String[] args) {
        FastScanner sc=new FastScanner();
        // int T=sc.nextInt();
        // for (int tt=0; tt<T; tt++) {
            n = sc.nextInt();
            arr = sc.readArray(n);
            long ans = 0;
            int max = arr[0];
            for(int i=1; i<n; i++) {
                if(max > arr[i]) ans+=(max-arr[i]);
                max = Math.max(max,arr[i]);
            }
            System.out.println(ans);
        //}
    }

    static final Random random=new Random();
    
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

    
}


Measured memory_bytes: 55308
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n,nn,digit_sum=0;
  scanf("%lld",&n);
  nn=n;
  while(nn!=0)
  {
    digit_sum+=nn%10;
    nn/=10;
  }
  puts(n%digit_sum?"No":"Yes");
  return 0;
}

Measured memory_bytes: 128
import itertools

H, W, K = map(int, input().split())
A = [[int(x) for x in input()] for _ in range(H)]


def solve(blocks):
    n_vert_cut = 0
    n_block = len(blocks)
    vals = [0 for _ in range(n_block)]

    for c in range(W):
        adds = [block[c] for block in blocks]
        if any(add > K for add in adds):
            return H * W

        sums = [val + add for val, add in zip(vals, adds)]
        if any(x > K for x in sums):
            n_vert_cut += 1
            vals = adds
        else:
            vals = sums

    return n_vert_cut + n_block - 1


ans = H * W
for mask in itertools.product([0, 1], repeat=H - 1):
    mask = [1] + list(mask) + [1]
    pivots = [r for r in range(H + 1) if mask[r]]
    blocks = [A[p1:p2] for p1, p2 in zip(pivots[:-1], pivots[1:])]
    blocks = [[sum(row[c] for row in block) for c in range(W)] for block in blocks]
    # print(blocks, '->', solve(blocks))
    ans = min(ans, solve(blocks))
print(ans)


Measured memory_bytes: 76636
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printDimention(DVector);

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int k;
    cin >> n >> k;
    
    int repet = n /k;
    int rem = n % k;
    
    ll res = pow(repet, 3);
    if(k % 2 == 0){
        if(k / 2 <= rem){
            res += pow(repet + 1, 3);
        }else{
            res += pow(repet, 3);
        }
    }
    cout << res << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
from operator import add, mul, sub, or_


class BIT:
    def __init__(self, n, op, ie):
        self.n = n
        self.tree = [ie]*(n+1)
        self.op = op
        self.ie = ie

    def update(self, i, v):
        while i <= self.n:
            self.tree[i] = self.op(self.tree[i], v)
            i += i & -i

    def query(self, i):
        v = self.ie
        while i:
            v = self.op(self.tree[i], v)
            i -= i & -i
        return v


N, Q = map(int, input().split())
*c, = map(int, input().split())

q = [[] for _ in range(N+1)]
for i in range(Q):
    x, y = map(int, input().split())
    q[y-1].append([i, x-1])

bit = BIT(N, add, 0)
finds = [-1]*(N+1)
ans = [0]*Q
for i in range(N):
    if finds[c[i]] != -1:
        bit.update(finds[c[i]]+1, -1)

    finds[c[i]] = i
    bit.update(finds[c[i]]+1, 1)

    for j, x in q[i]:
        ans[j] = bit.query(i+1) - bit.query(x)

for a in ans:
    print(a)


Measured memory_bytes: 223396
import sys

def main():
    row, col = sys.stdin.readline().strip().split(' ')
    row = int(row)
    col = int(col)

    row_sums = []
    for _ in range(row):
        row_sums.append(0)

    col_sums = []
    for i in range(col):
        col_sums.append(0)
        
    for i in range(row):
        line = sys.stdin.readline().strip()
        data = [int(i) for i in line.split(' ')]

        for j in range(col):
            row_sums[i] += data[j]
            col_sums[j] += data[j]
            
        print(line, row_sums[i])

    sum = 0
    for i in range(col):
        print('{} '.format(col_sums[i]), end='')
        sum += col_sums[i]
        
    print(sum)
    
if __name__ == '__main__':
    main()
    

Measured memory_bytes: 7764
n=int(input())
l=[int(i) for i in input().split()]
res=[0 for i in range(n)]
now=0
for i in range(n-1):
    now=l[i]-now
    res[i+1]=now
diff=(res[-1]+res[0]-l[-1])//2
for i in range(n):
    if i%2==0:
        print(2*(res[i]-diff),end=" ")
    else:
        print(2*(res[i]+diff),end=" ")

Measured memory_bytes: 65380
n,m=gets.chomp.split(' ').map(&:to_i)
arr = []
m.times do
    arr << gets.chomp.split(' ')
end
hash = {}
arr.each do |a|
    if hash[a[0].to_i].nil?
        hash[a[0].to_i] = [a]
    else
        hash[a[0].to_i] << a
    end 
end
ans = [0,0]
hash.keys.each do |h|
    wa_num = 0
    hash[h].each do |t|
        if t[1]=="AC"
            ans[1] += wa_num 
            ans[0]+=1
            break
        else
            wa_num += 1
        end
    end
end
puts ans.join(' ')

Measured memory_bytes: 32636
#!/usr/bin/env python3
from collections import deque
q = deque([0])
Dequeue = lambda: q.popleft()
Enqueue = lambda x: q.append(x)
n, m = map(int, input().split())
l = [[] for _ in [0]*n]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    l[a] += [b]
    l[b] += [a]
ans = [-1]*n
while q:
    v = Dequeue()
    for i in l[v]:
        if ans[i] < 1:
            ans[i] = v+1
            Enqueue(i)
if -1 in ans:
    print('No')
else:
    print('Yes')
    for j in ans[1:]:
        print(j)


Measured memory_bytes: 37676
N, K = map(int, input().split())
s = input()

l, r = 0, 0
for i in range(K):
    while r < N and s[r] == '1': r += 1
    while r < N and s[r] == '0': r += 1
# K回直立→逆立ちの反転操作を行う
while r < N and s[r] == '1': r += 1
# 元々逆立ちしている人の右端まで行く
ans = r - l
# 区間の人数をansに代入
while r < N:
    while l < r and s[l] == '1': l += 1
    while l < r and s[l] == '0': l += 1
    # 左端を右にずらす
    # 出来るだけ人数が多くなるように区間を縮めるので、
    # 0==直立の区間直後まで動かす
    while r < N and s[r] == '0': r += 1
    while r < N and s[r] == '1': r += 1
    # 右端を右にずらす
    # できるだけ人数が多くなるように区間を広げるので、
    # 1==逆立ちの区間の直後まで動かす
    ans = max(ans, r - l)
    # 区間の人数をansに代入
print(ans)

# 尺取り法

Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 int MOD = 1000000007;
int rui(int a, int b) {
    if(b == 0) {
        return 1;
    }
    return rui(a, b - 1) * a;
}
int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);

    rep(i, 0, N) {
        cin >> m[i];
        X -= m[i];
    }
    int mi = *min_element(m.begin(), m.end());
    cout << N + X / mi << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    if(S.substr(0,4) == "YAKI"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 764
#prag\
ma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
typedef long long LL ;
const int MAXN = 200000 ;
#define min( a , b ) ( a < b ? a : b )
using namespace std;

inline LL read ( ) {
    LL x = 0 , w = 1 ; char c = ' ' ;
    while ( c < '0' || c > '9' ) { c = getchar ( ) ; if ( c == '-' ) w = -1 ; }
    while ( c >= '0' && c <= '9' ) { x = ( x << 1 ) + ( x << 3 ) + ( c ^ '0' ) , c = getchar ( ) ; }
    return x * w ;
}

LL a[MAXN + 5] ;

struct Node {
	LL val , t ;  
	Node ( LL a , LL b ) { val = a , t = b ; }
	bool operator < ( const Node & a ) const {
		return t < a.t ;
	}
} ;

map < LL , LL > H ;
map < LL , LL > :: iterator it ;
multiset < Node > S ;

int main ( ) {
	LL n = read ( ) , k = read ( ) , sum = 0 ;
	
	for ( int i = 1 ; i  <= n ; ++i ) {
		LL x = read ( ) ;
	 	if ( !H[x] ) ++H[x] , ++sum ; else ++H[x] ;
	}
	
	for ( it = H.begin ( ) ; it != H.end ( ) ; ++it )
		S.insert ( Node ( it -> first , it -> second )  ) ; 
	
	if ( k >= sum ) {
		puts ( "0" ) ;
		return 0 ;
	}
	
	LL tmp = sum - k , Ans = 0 ;
	
	while ( tmp > 0 && !S.empty ( ) ) {
		Node temp = *S.begin ( ) ; 
		while ( 1 ) {
			++Ans ;
			--temp.t ;
			if ( temp.t == 0 ) {
				S.erase ( S.begin ( ) ) ; break ;
			}
		}
		--tmp ;
	}
	
	cout << Ans << endl ;

	return 0 ;
}

Measured memory_bytes: 25216
MOD = 10**9 + 7
N,K = map(int,input().split())
ans = 0
for n in range(K,N+2):#数はN+1個
    ans += (N*2 -n + 1)*n//2  -  n*(n-1)//2 +1
    ans %= MOD
print(ans)

Measured memory_bytes: 63416
#include<cstdio>

int main(){
    int a, b;
    scanf ("%d %d", &a, &b);
    
    int d = a / b;
    int r = a % b;
    double f = (double)a / (double)b;
    
    printf("%d %d %f\n", d, r, f );
    
    return 0;
}


Measured memory_bytes: 2748
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n,t,J,bell,ans,ANS;
  char s[10],ring[10];
  cin >> s;
  n=strlen(s);
  cin >> t;
  ANS=0;
  for(int i=0;i<t;i++){
    cin >> ring;
    ans=0;
 
    for(int j=0;j<10;j++){
      bell=0;
      J=j;
      for(int k=0;k<n;k++,J++){
	if(J==10){
	  J=0;
	}
	if(s[k]==ring[J]){
	  bell++;
	}
      }
      if(bell==n){
	ans++;
      }
    }

    if(ans>0){
      ANS++;
    }
  }

  cout << ANS << endl;
}

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

int main() {
  int N, M, b, a;
  b = 1000000;
  a = 0;
  int t = 0;
  cin >> N >> M;
  vector<vector<int>> C(M, vector<int>(2));
  for(int i = 0; i < M; i++){
    cin >> C.at(i).at(0) >> C.at(i).at(1);
  }
  for(int i = 0; i < M; i++){
    a = max(a,C.at(i).at(0));
  }
  for(int i = 0; i < M; i++){
    b = min(b,C.at(i).at(1));
  }


    for(int j = 1; j < N+1; j++){
        if(b>= j && j >= a) t++;
    }

    cout << t << endl;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				Integer H = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer W = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				if (H == 0 && W == 0) {
					return;
				}
				for (int i = 0; i < H; i++) {
					if (i == 0 || i == H - 1) {
						for (int j = 0; j < W; j++) {
							System.out.print("#");
						}
					}
					else {
						for (int j = 0; j < W; j++) {
							if (j == 0 || j == W - 1) {
								System.out.print("#");
							}
							else {
								System.out.print(".");
							}
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 31756
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1000000];
	cin>>n;
	int c[1000000];
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		c[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<c[i]<<endl;
	}
}

Measured memory_bytes: 5140
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
XY = [0] * N
ans = 0
for i in range(N):
    XY[i] = V[i]-C[i]
    if XY[i] >= 0:
        ans += XY[i]
print(ans)

Measured memory_bytes: 3064
while True:
    a, op, b = raw_input().split()
    ai = int(a)
    bi = int(b)
    if op == '?':
        break
    elif op == '+':
        print(ai + bi)
    elif op == '-':
        print(ai - bi)
    elif op == '*':
        print(ai * bi)
    elif op == '/':
        print(ai / bi)

Measured memory_bytes: 6368
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string s, t;
    cin >> s >> t;
    Int length = s .length();
    Int count = 0;
    for (Int i = 0; i < length; ++i) {
        if (s[i] == t[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3620
#pragma GCC optimize("O3") 

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

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	        cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
  ll n;
  cin >> n;
  ll r = n % 1000;
  if(r == 0)
    cout << 0 << endl;
  else
  	cout << 1000-r << endl;
}

int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define mt                make_tuple
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define deb(x)			  cerr << "# " << (#x) << " = " << (x) << endl;
#define sz(x)             (int)x.size()
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

const ll mod = 998244353LL;

const int tam = 2e5 + 10;

int T[4*tam], lazy[4*tam];

#define index int L = 2*nodo+1, R = L+1, mid = (b+e)>>1;

void propagate(int b, int e, int nodo) {
    index;
    if (lazy[nodo] == 0) return;
    T[nodo] += lazy[nodo];
    T[nodo] %= mod;
    if (b != e) {
        lazy[L] += lazy[nodo];
        lazy[L] %= mod;
        lazy[R] += lazy[nodo];
        lazy[R] %= mod;
    }
    lazy[nodo] = 0;
}

void update(int b, int e, int nodo, int i, int j, int val) {
    index;
    propagate(b, e, nodo);
    if (j < b || e < i) return;
    if (i <= b && e <= j) {
        lazy[nodo] += val;
        lazy[nodo] %= mod;
        propagate(b, e, nodo);
        return;
    }
    update(b,   mid, L, i, j, val);
    update(mid+1, e, R, i, j, val);
    T[nodo] = max(T[L], T[R]);
}

int query(int b, int e, int nodo, int i, int j) {
    index;
    propagate(b, e, nodo);
    if (j < b || e < i) return 0;
    if (i <= b && e <= j) return T[nodo];
    return max(
        query(b, mid, L, i, j),
        query(mid+1, e, R, i, j)
    );
}

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int n, k;
    cin >> n >> k;
    vii s(k);
    fore(i, 0, k) {
        cin >> s[i].F >> s[i].S;
    }
    update(0, n-1, 0, 0, 0, 1);
    fore(i, 0, n-1) {
        int val = query(0, n-1, 0, i, i);
        for (ii seg : s) {
            int l = seg.F;
            int r = seg.S;
            l = i + l;
            r = min(i + r, n-1);
            if (r < l) continue;
            update(0, n-1, 0, l, r, val);
        }
    }
    cout << query(0, n-1, 0, n-1, n-1)%mod << '\n';
    return 0;
}
// Dinosaurs are cool!

Measured memory_bytes: 7688
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

const int N = 300100;

int n, x[N];

int main() {
    int i;
    //freopen("ttt", "r", stdin);

    scanf("%d", &n);
    for(i = 1; i <= 3 * n; ++i)
        scanf("%d", &x[i]);

    sort(x + 1, x + 3 * n + 1);

    long long s = 0;

    for(i = 1; i <= n; ++i) {
        s += x[3 * n - i * 2 + 1];
    }

    cout << s;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 1e6 + 5;

ll n,k;
ll a[MAXN];
//判断在当前的数之前有多少个数
ll check(ll x){
	ll res=0;
	for(int i=0;i<n;i++){
		if(a[i]<0){
			ll L=i,R=n;
			while(R-L>1){
				ll mid=L+R>>1;
				if(a[i]*a[mid]<=x){//这里要注意和下面不一样的是 当a[i]<0的时候mid取小 乘积反而会增大
					R=mid;
				}else{
					L=mid;
				}
			}
			res+=n-R;
		}else{
			ll L=i,R=n;
			while(R-L>1){
				ll mid=L+R>>1;
				if(a[i]*a[mid]<=x){//a[i]>0 mid取大 乘积增大
					L=mid;
				}else{
					R=mid;
				}
			}
			res+=L-i;
		}
	}
	return res;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll L=-1e18,R=1e18;
	while(R-L>1){
		ll Mid=L+R>>1;
		if(check(Mid)<k){
			L=Mid;
		}else{
			R=Mid;
		}
	}
	cout<<R;
	return 0;
}



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

int main() {
  int A,B,C;
  cin >>  A >> B >> C;

  if (((A<C)&&(C<B))||((B<C)&&(C<A)))
    cout << "Yes" << endl;
  else 
    cout << "No"  << endl;
        
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

ll f(vector<ll>& a, bool flag)
{
    ll s = 0;
    ll pm = (flag) ? 1 : -1;
    ll ret = 0;
    for(int i=0; i<a.size(); i++){
        if((s + a[i]) * pm <= 0){
            ret += (s + a[i]) * pm * -1 + 1;
            s = pm;
        }
        else{
            s += a[i];
        }
        pm *= -1;
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(ll& x: a) cin >> x;

    cout << min(f(a, true), f(a, false)) << endl;
}

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

const int N = 2005;

long long dp[N * 3][N];

int main() {
	int n, m;
	cin >> n >> m;
	dp[0][0] = 1;
	for (int i = 1; i <= n * 3; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] += dp[i - 1][j];
			if (i > 1 && j > 0) {
				dp[i][j] += 1ll * (i - 1) * dp[i - 2][j - 1];
			}
			if (i > 2 && j > 0) {
				dp[i][j] += 1ll * (i - 1) * (i - 2) * dp[i - 3][j - 1];
			}
			dp[i][j] %= m;
		//	cout << "73 " << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		ans += dp[n * 3][i];
	}
	cout << ans % m;
	return 0;
}


Measured memory_bytes: 94464
N = int(input())

x=[]
y=[]
h=[]

for i in range(N):
	x_i,y_i,h_i = list(map(int,input().split()))
	x.append(x_i)
	y.append(y_i)
	h.append(h_i)

s = 0
flag = 0
s_max=2000000000
x_a=0
y_a=0
h_a=0

for C_X in range(101):
	for C_Y in range(101):
		for i in range(N):
			if h[i]!=0:
				if s==0:
					s = abs(x[i]-C_X)+abs(y[i]-C_Y)+h[i]
					#print("%d %d %d set" % (C_X,C_Y,s))
				elif abs(x[i]-C_X)+abs(y[i]-C_Y)+h[i] != s:
					#print("%d %d %d failed" % (C_X,C_Y,s))
					s=0
					s_max=2000000000
					break
			else:
				if abs(x[i]-C_X)+abs(y[i]-C_Y) < s_max: s_max=abs(x[i]-C_X)+abs(y[i]-C_Y)
			if s_max < s:
				s=0
				s_max=2000000000
				break
			if i==N-1:
				h_a=s
				flag=2
				break
		if flag:
			y_a=C_Y
			break
	if flag:
		x_a=C_X
		break

print("%d %d %d" % (x_a,y_a,h_a))


Measured memory_bytes: 3064
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)

iceil(x) = Int64(ceil(x))
ifloor(x) = Int64(floor(x))
function main()
r,g,b,n = map(parseInt, split(readline()))
a = 0
for i1 = 0:ifloor(n/r+1)
  for i2 = 0:ifloor((n-i1*r)/g)
    if mod(n - i1*r - i2*g,b) == 0
      a +=1
    end
  end

end
println(Int64(a))
end
main()


Measured memory_bytes: 170600
#include <bits/stdc++.h>
#define nmax 100001
using namespace std;

int arr[nmax],n;
long long dp[nmax];

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

    cin>>n;
    for(int i=1;i<=n;i++) cin>>arr[i];
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);
    for(int i=3;i<=n;i++){
        dp[i]=min((abs(arr[i-1]-arr[i]) + dp[i-1]),(abs(arr[i-2]-arr[i]) + dp[i-2]) );
    }
    cout<<dp[n];
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int q; cin >> q;
	while(q--){
		int a, b; cin >> a >> b;
		if(a == b){
			cout << 2 * (a - 1) << endl;
			continue;
		}
		
		if(a > b) swap(a, b);
		ll ans = a - 1;
		
		double t = (sqrt(4.0 * a * b - 3) - 1) / 2;
		int lim = ceil(t);
		//dbg(a, b, lim, ((ll)a * b - 1) / lim);
		ans += lim + ((ll)a * b - 1) / lim - a - 1;
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  if(N%2==0)cout<<N<<endl;
  if(N%2==1)cout<<N*2<<endl;
}


Measured memory_bytes: 256