akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;

  int ans = 180 * (n - 2);
  cout<<ans<<endl;

  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
class Grid {
  template <typename U>
  using pqueue = std::priority_queue<U, std::vector<U>, std::greater<U>>;

 public:
  Grid(int height, int width) : grid_(height, std::vector<T>(width)) {}
  void Set(int row, int col, T value) { grid_[row][col] = value; }
  T Distance(int src_row, int src_col) {
    if (grid_[src_row][src_col] < 0) {
      return -1;
    }
    pqueue<std::tuple<T, int, int>> que;
    que.push(make_tuple(0, src_row, src_col));
    std::map<std::pair<int, int>, T> visited;
    visited[{src_row, src_col}] = 0;
    T ret = 0;
    while (!que.empty()) {
      T dist;
      int row, col;
      std::tie(dist, row, col) = que.top();
      que.pop();
      ret = max(ret, dist);
      int dr[] = {1, -1, 0, 0};
      int dc[] = {0, 0, 1, -1};
      for (int i = 0; i < 4; ++i) {
        int nrow = row + dr[i];
        int ncol = col + dc[i];
        if (nrow < 0 || grid_.size() <= nrow || ncol < 0 ||
            grid_[0].size() <= ncol || grid_[nrow][ncol] < 0) {
          continue;
        }
        int ndist = dist + grid_[nrow][ncol];
        const auto it = visited.find({nrow, ncol});
        if (it != visited.end() && it->second <= ndist) {
          continue;
        }
        visited[{nrow, ncol}] = ndist;
        que.push(make_tuple(ndist, nrow, ncol));
      }
    }
    return ret;
  }

 private:
  std::vector<std::vector<T>> grid_;
};

int main() {
  CIN(int,H,W);
  vector<string>m(H);
  REP(i,H)cin>>m[i];

  int ans=0;
  REP(sr,H)REP(sc,W){
    Grid<int> grid(H, W);
    REP(r,H)REP(c,W)grid.Set(r,c,m[r][c]=='.'?1:-1);
    ans=max(ans,grid.Distance(sr,sc));
  }
  COUT(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define ARRAY_MAX 100005


int main(){


    string str;
    cin >> str;
    bool n = false,s = false,w = false,e = false;
    REP(i,str.length()){
        if(str[i] == 'N'){
            n = true;
        }
        if(str[i] == 'W'){
            w = true;
        }
        if(str[i] == 'S'){
            s = true;
        }
        if(str[i] == 'E'){
            e = true;
        }
    }
    
    if((!(n^s)) && (!(w^e))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n,a,h=0;
    cin>>n;
    a=n;
    while(n){
    	h+=n%10;
    	n/=10;
    }
    if(a%h==0)cout<<"Yes";
    else cout<<"No";
	return 0;
}


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

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

  int N1, N2, N3, N4;
  N1 = N.at(0);
  N2 = N.at(1);
  N3 = N.at(2);
  N4 = N.at(3);


  string res = "No";
  if(N.at(1) == N.at(2)){
    if(N.at(0) == N.at(1) || N.at(2) == N.at(3)){
      res = "Yes";
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
greedyに高い金額から割り引いていく
"""

from heapq import heappop,heappush,heapify

N,M = map(int,input().split())
A = [int(x) for x in input().split()]

A_minus = [-x for x in A]
heapify(A_minus)

pop = lambda: -heappop(A_minus)
push = lambda x: heappush(A_minus,-x)

for _ in range(M):
    x = pop()
    push(x//2)

answer = -sum(A_minus)
print(answer)

Measured memory_bytes: 14200
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var k = toInt(input[0]);
	var ans = Math.floor(k/2)*Math.floor((k+1)/2);

	console.log(ans);
}

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep2(i, x, n) for(int i = x; i < (n); ++i)

int main()
{
    int n;
    int res = 0;
    cin >> n;
    int temp;
    rep2(i, 1, n+1) {
        cin >> temp;
        if (i % 2 == 1 && temp % 2 == 1) res++;
    }
    cout << res << endl;
    return 0;
}

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

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

int main() {
  int a,b;
  cin >> a >>b;
  if(a<=0 || a>=10 || b <=0 || b>=10)  cout << "-1" << endl;
  else cout << a*b << endl;

	return 0;		
}

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

int main()
{
  int a, b;
  cin >> a >> b;

  string A, B;
  for (int i = 0; i < b; i++)
  {
    A += to_string(a);
  }
  for (int i = 0; i < a; i++)
  {
    B += to_string(b);
  }
  cout << min(A, B) << endl;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(){
  int v, e; cin >> v >> e;
  vector<vector<int> > a(v);
  vector<int> ind(v, 0), c(v, 0), ans;
  for(int i = 0; i < e; i++){
    long long s, t; cin >> s >> t;
    a[s].push_back(t);
    ind[t]++;
  }
  for(int i = 0; i < v; i++){
    if(ind[i] == 0 && c[i] == 0){
      queue<int> q;
      q.push(i);
      c[i] = 1;
      while(q.size() > 0){
        int x = q.front();
        q.pop();
        ans.push_back(x);
        for(int j = 0; j < a[x].size(); j++){
          ind[a[x][j]]--;
          if(ind[a[x][j]] == 0 && c[a[x][j]] == 0){
            q.push(a[x][j]);
            c[a[x][j]] = 1;
          }
        }
      }
    }
  }
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }
  return;
}

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



Measured memory_bytes: 3744
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/10;

string days[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int m, d;
	while(cin >> m >> d, m) {
		int res = 0;
		for(int i = 1; i < m; i++) {
			res += day[i-1];
		}
		res += (d-1);

		cout << days[res%7] << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    vector<ll> L(4);
    ll N;
    for (int i = 0; i < 4; i++) {
        cin >> L.at(i);
    }
    cin >> N;
    N *= 4;
    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 4; j++) {
            ll tmp = L[i] * (1 << (j - i));
            chmin(L[j], tmp);
        }
    }

    ll ans = 0;
    for (int i = 4 - 1; i >= 0; i--) {
        ll s = N / (1LL << (i));
        ans += L[i] * s;
        N -= s * (1LL << i);
    }
    cout << ans << endl;
}


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

#define INF 1000000001
#define N_MAX 500005

int S[N_MAX];
int cnt;

void merge(int S[], int left, int mid, int right) {
    int n_left = mid - left;
    int n_right = right - mid;

    int L[N_MAX/2+2], R[N_MAX/2+2];
    for (int i = 0; i < n_left; i++) {
        L[i] = S[left + i];
    }
    for (int i = 0; i < n_right; i++) {
        R[i] = S[mid + i];
    }
    L[n_left] = INF;
    R[n_right] = INF;

    int idx_L = 0;
    int idx_R = 0;

    for (int k = left; k < right; k++) {
        cnt++;
        if (L[idx_L] <= R[idx_R]) {
            S[k] = L[idx_L];
            idx_L++;
        }
        else {
            S[k] = R[idx_R];
            idx_R++;
        }
    }

    // while (L[idx_L] != INF || R[idx_R] != INF) {
    //     if (L[idx_L] <= R[idx_R]) {
    //         S[left + idx_L + idx_R] = L[idx_L];
    //         idx_L++;
    //     }
    //     else {
    //         S[left + idx_L + idx_R] = R[idx_R];
    //         idx_R++;
    //     }
    // }

}

void mergeSort(int S[], int left, int right) {
    if (right - left > 1) {
        int mid = (left + right) / 2;
        mergeSort(S, left, mid);
        mergeSort(S, mid, right);
        merge(S, left, mid, right);
    }
}

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

    cnt = 0;
    int left = 0;
    int right = n;
    mergeSort(S, left, right);

    for (int i = 0; i < n; i++) {
        if (i != 0) {
            cout << " ";
        }
        cout << S[i];
    }
    cout << endl;
    cout << cnt << endl;
}



Measured memory_bytes: 6972
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

ll optPref[MAXN];

ll optSuff[MAXN];

int arr[MAXN];

int n, k;

ll ans;

void solve() {                   
	scanf("%d %d", &n, &k);
	ll sum = 0;

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);

    	if (i <= k) {
    		sum += arr[i];
    	}
    }

	for (int i = 1; i <= n; ++i) {
		optPref[i] = optPref[i - 1] + max(0, arr[i]);
	}

	for (int i = n; i > 0; --i) {
		optSuff[i] = optSuff[i + 1] + max(0, arr[i]); 
	}

	for (int l = 1; l + k - 1 <= n; ++l) {
		ans = max(ans, max(0ll, sum) + optPref[l - 1] + optSuff[l + k]);
		sum += arr[l + k] - arr[l];		
	}

	printf("%lld\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,l,r;

bool check(ll y,const vector<ll> &v){
    bool res;
    rep(i,v.size()){    
        if(y % v[i] == 0)return i%2 == 0;
    }
    return v.size()%2 == 0;
}

int main(){
    while(cin >> n >> l >> r && n){
        vector<ll> v(n);
        rep(i,n)cin >> v[i];
        ll ans = 0;
        for(ll i = l;i <= r;i++){
            if(check(i,v))ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N;

int main()
{
	in >> N;
	out << N*(N + 1) / 2 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
int k;
int T[SIZE];

bool check(int m){
	int cw = 0;
	int car=1;
	for(int i=0;i<n;i++){
		if(T[i]>m)return false;
		else if(T[i]+cw>m){
			cw = T[i];
			car++;
			if(car>k)return false;
		}else{
			cw += T[i];
		}
	}
	return true;
}

int main()
{
	scanf("%d %d",&n,&k);
	int r=0;
	for(int i=0;i<n;i++){
		scanf("%d",&T[i]);
		r+=T[i];
	}
	r++;
	int l=0,m;
	while(l+1<r){
		m=(l+r)/2;
		if(check(m))r=m;
		else l=m;
	}
	printf("%d\n",r);
	return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}


int main(){
    ll h,w;cin >> h >>w;
    ll ch,cw,dh,dw;cin >> ch >> cw >> dh >> dw;ch--;cw--;dh--;dw--;
    vector<string> g(h);rep(i,h)cin >> g[i];
    vvl seen(h,vl(w,inf));
    deque<pl> que;
    que.push_front({ch,cw});
    seen[ch][cw]=0;
    while(!que.empty()){
        pl p=que.front();que.pop_front();
        rep(i,4){
            ll ny=p.fi+dy[i],nx=p.se+dx[i];
            if(ny<0||nx<0||ny>=h||nx>=w)continue;
            if(g[ny][nx]=='#')continue;
            if(chmin(seen[ny][nx],seen[p.fi][p.se])){
                que.push_front({ny,nx});
            }
        }
        rep(i,5){
            rep(j,5){
                ll ny=p.fi-2+i,nx=p.se-2+j;
                if(ny<0||nx<0||ny>=h||nx>=w)continue;
                if(g[ny][nx]=='#')continue;
                if(chmin(seen[ny][nx],seen[p.fi][p.se]+1)){
                    que.push_back({ny,nx});
                }
            }
        }
    }
    /*rep(i,h){
        rep(j,w){
            cout << seen[i][j]<<" ";
        }
        cout << endl;
    }*/
    if(seen[dh][dw]==inf)cout << -1 <<endl;
    else cout << seen[dh][dw] <<endl;
}

Measured memory_bytes: 13468
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const int INF = 1000000009;

int n, m;
vector<int> edge[50];
bool used[50];

bool judge(int i, int j, int dep){
	//true->帰ってきた！みつけた！！
	//false->みつからなかったお
	if(used[j]){
		return false;
	}
	used[j] = true;
	bool flag = false;
	for(int k = 0; k < edge[j].size(); k++){
		if(edge[j][k] == i){
			if(dep == 0){
				continue;
			}else{
				return true;
			}
		}
		if(judge(i, edge[j][k], dep+1)){
			return true;
		}
	}
	return false;
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	/*for(int i = 0; i < m; i++){
		printf("%d - ", i);
		for(int j = 0; j < edge[i].size(); j++){
			printf("%d ", edge[i][j]);
		}
		printf("\n");
	}*/
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < edge[i].size(); j++){
			for(int k = 0; k < 50; k++){
				used[k] = false;
			}
			if(!judge(i, edge[i][j], 0)){
				//printf("%d %d\n", i, edge[i][j]);
				ans++;
			}
		}
	}
	printf("%d\n", ans/2);
	return 0;
}

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


signed main() {
    int n, q;
    cin >> n;
    vector<int> s(n);
    rep(i,n) cin >> s[i];
    cin >> q;
    vector<int> t(q);
    rep(i,q) cin >> t[i];
    int ans = 0;
    rep(i,q){
        int r = n, l = 0;
        while(r-l>1){
            int m = (r+l)/2;
            if(s[m]<=t[i]) l = m;
            else r = m;
        }
        if(s[l]!=t[i]) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int64_t> A(N);
	int64_t minA = (1e9) + 1;
	int64_t sum = 0;
	int minus = 0;
	for (auto&i:A) {
		cin >> i;
		minA = min(minA, abs(i));
		if (i<0) {
			minus++;
		}
		sum += abs(i);
	}

	if (minus%2) {
		sum -= (minA*2);
	}

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 1024
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n,@c = gets.split.map(&:to_i)
    @x,@v = Array.new(n){ gets.split.map(&:to_i) }.transpose
  end

  def init
    init_left
    init_right
  end

  def cs(a)
    a.each_with_object([0]) { |v, h| h << h[-1] + v }
  end

  def cs_max(a)
    ans = a.each_with_object([-10**15]) { |v,h| h << [h[-1], v].max }
    ans[1..]
  end

  def init_left
    @left_x = [0] + x
    @left = cs(v)
    @left_d = @left.zip(@left_x).map{|a,b|a-b}
    @left_2d = @left_d.zip(@left_x).map{|a,b|a-b}
    @left_d_max = cs_max(@left_d)
    @left_2d_max = cs_max(@left_2d)
  end

  def init_right
    @right_x = [0] + x.reverse.map { c - _1 }
    @right = cs(v.reverse)
    @right_d = @right.zip(@right_x).map{|a,b|a-b}
    @right_2d = @right_d.zip(@right_x).map{|a,b|a-b}
    @right_d_max = cs_max(@right_d)
    @right_2d_max = cs_max(@right_2d)
  end

  def solve
    init
    ans = 0
    0.upto(n) do |i|
      j = n - i
      ans = max(ans, @left_2d_max[i] + @right_d_max[j])
      ans = max(ans, @left_d_max[i] + @right_2d_max[j])
    end
    ans
  end

  def show(ans)
    pp ans
  end

  def max(a,b)
    a < b ? b : a
  end

  def max_with_index(a)
    maxi = a.max
    [maxi, a.index(maxi)]
  end
end

Problem.new.instance_eval do
  show(solve)
  # init
  # pp self
end

Measured memory_bytes: 34464
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, x;
	cin >> n >> x;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];
	}
	int ans = 0;
	zip(i, 0, n - 1)
	{
		if (a[i] + a[i + 1] > x)
		{
			int p = a[i + 1] + a[i] - x;
			if (p < a[i + 1])
			{
				ans += p;
				a[i + 1] -= p;
				p = 0;
			}
			else
			{
				a[i + 1] = 0;
				ans += a[i + 1];
				p -= a[i + 1];
				a[i] -= p;
				ans += p;
			}
		}
	}
	cout << ans << en;


	return 0;
}



Measured memory_bytes: 4436
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	ll i, n, st, cnt;
	string s, t;
	cin >> n;
	cin >> s;
	cin >> t;
	if (s[0] == t[0]) st = 0, i = 1, cnt = 3;
	else st = 1, i = 2, cnt = 6;
	while (i < n) {
		if (st == 0) {
			if (s[i] == t[i]) cnt *= 2;
			else cnt *= 2, st = 1, i++;
		}
		else {
			if (s[i] == t[i]) cnt *= 1, st = 0;
			else cnt *= 3, i++;
		}
		cnt %= PRIME;
		i++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
    char s[5];
    scanf("%s",s);
    int i, flag;
    flag = 1;
    for(i = 0; i < 3; i++) {
        if(s[i]==s[i+1]) {
            flag = 0;
        }
    }
    if(flag == 1) {
        printf("Good\n");
    } else {
        printf("Bad\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=2000+10;
char s[maxn];
int a[maxn],b[maxn],c[maxn],L[maxn],R[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,ans,num,sum,cnt,mx,mi,top;
bool czy,gjx;
bool cmpL(int x,int y){
	return L[x]<L[y];
}
bool cmpR(int x,int y){
	return R[x]<R[y];
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	czy=1;
	fo(i,1,n){
		a[i]=s[i]-'0';
		if (a[i]) czy=0;
	}
	scanf("%s",s+1);
	gjx=1;
	fo(i,1,n){
		b[i]=s[i]-'0';
		if (b[i]) gjx=0;
	}
	if (gjx){
		if (czy) printf("0\n");else printf("-1\n");
		return 0;
	}
	fo(i,1,n){
		j=i;
		while (!b[j]){
			L[i]++;
			if (j==1) j=n;
			else j--;
		}
		j=i;
		while (!b[j]){
			R[i]++;
			if (j==n) j=1;
			else j++;
		}
	}
	ans=1000000000;
	fo(i,1,n){
		fo(j,1,n) bz[j]=0;
		sum=0;
		j=i;
		fo(k,1,n){
			if (a[j]!=b[k]) bz[j]=1,sum++;
			if (j==n) j=1;else j++;
		}
		cnt=(i==1?0:n-i+1);
		top=0;
		fo(j,1,n)
			if (bz[j]&&R[j]>cnt) c[++top]=j;
		sort(c+1,c+top+1,cmpL);
		mx=0;mi=5*n;
		if (top) mi=min(mi,L[c[top]]*2+cnt);
		fd(j,top,1){
			mx=max(mx,R[c[j]]);
			if (j>1) mi=min(mi,L[c[j-1]]*2+mx*2-cnt);
		}
		if (top) mi=min(mi,mx*2-cnt);
		if (!top) mi=cnt;
		num=mi;
		ans=min(ans,num+sum);
		cnt=i-1;
		top=0;
		fo(j,1,n)
			if (bz[j]&&L[j]>cnt) c[++top]=j;
		sort(c+1,c+top+1,cmpR);
		mx=0;mi=5*n;
		if (top) mi=min(mi,R[c[top]]*2+cnt);
		fd(j,top,1){
			mx=max(mx,L[c[j]]);
			if (j>1) mi=min(mi,R[c[j-1]]*2+mx*2-cnt);
		}
		if (top) mi=min(mi,mx*2-cnt);
		if (!top) mi=cnt;
		num=mi;
		ans=min(ans,num+sum);
	}
	printf("%d\n",ans);
}

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

int main() {
  int A , B , C;
  cin >> A >> B >> C;
 
  if (A == B && A != C) {
    cout << "Yes" << endl;
  }
  else if (A == C && A != B)
  {
    cout << "Yes" << endl;
      }
  else if (B == C && A != B )
  {
   cout << "Yes"<< endl;
  }    
  else {
    cout << "No" << endl;
  }
 
}
   


Measured memory_bytes: 256
def main():
    W, H, N = map(int, input().split())
    P = [tuple(map(int, input().split())) for _ in range(N)]

    x = [0, W]
    y = [0, H]
    for p in P:
        if p[2] == 1 and x[0] < p[0]:
            x[0] = p[0]
        elif p[2] == 2 and x[1] > p[0]:
            x[1] = p[0]
        elif p[2] == 3 and y[0] < p[1]:
            y[0] = p[1]
        elif p[2] == 4 and y[1] > p[1]:
            y[1] = p[1]

    region = [x[1] - x[0], y[1] - y[0]]
    if region[0] <= 0 or region[1] <= 0:
        area = 0
    else:
        area = region[0] * region[1]

    print(area)

main()


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
//#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
ll cnt[2020];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    string s;cin>>s;
    ll ans=0;
    cnt[0]=1;
    ll now=0;
    ll d=1;
    for(ll i=s.length()-1;i>=0;i--){
        now+=(s[i]-'0')*d%2019;
        now%=2019;
        cnt[now]++;
        ans+=(cnt[now]-1);
        d*=10;
        d%=2019;
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 3820
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;r;end

function main()
	n,m = readline() |> split |> parseMap
	s = parseMap(split(chomp(readline()), ""))
	a = Int[]
	for i in 1:n+1
		if s[i]==0
			push!(a,i)
		end
	end
	ans = Int[]
	now = n+1
	f = 0
	while now>1
		x = bsearch(a,now-m)
		if a[x]==now
			f = 1
			break
		end
		push!(ans,now-a[x])
		now = a[x]
	end
	if f == 1
		println(-1)
	else
		for i in length(ans):-1:2
			print(ans[i]," ")
		end
		println(ans[1])
	end
end
main()

Measured memory_bytes: 167880
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool used[1010101];

int main(){
    int n;
    cin>>n;
    int ans=1;
    while(!used[n]){
        used[n]=true;
        if(n%2)n=3*n+1;
        else n/=2;
        ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  int count = 0;
  rep(i, n) { cin >> l[i]; };
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
          if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3632
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import bisect
import math
import fractions
import sys
import copy


def L(): return sys.stdin.readline().split()


def I(): return int(sys.stdin.readline().rstrip())


def SL(): return list(sys.stdin.readline().rstrip())


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def IR(n): return [I() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def LIR1(n): return [LI1() for _ in range(n)]


def SR(n): return [SL() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def LR(n): return [L() for _ in range(n)]


def perm(n, r): return math.factorial(n) // math.factorial(r)


def comb(n, r): return math.factorial(
    n) // (math.factorial(r) * math.factorial(n-r))


alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")


def main():
    N = I()
    L = LI()

    ans = 0
    for (a, b, c) in itertools.combinations(L, 3):
        if a < b + c and abs(b - c) < a and a != b and b != c and a != c:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72920
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if (n >= 10) {
            System.out.println(r);
        } else {
            System.out.println(r+((100)*(10-n)));
        }
    }
}

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

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    int x[N], y[N], a[N];
    REP(i,N) cin >> x[i] >> y[i] >> a[i];
    int l = 0, r = W, d = 0, u = H;
    // cout << l << r << d << u << endl;
    REP(i, N){
        if (a[i] == 1){
            if (l < x[i]) l = x[i];
        }
        if (a[i] == 2){
            if (r > x[i]) r = x[i];
        }
        if (a[i] == 3){
            if (d < y[i]) d = y[i];
        }
        if (a[i] == 4){
            if (u > y[i]) u = y[i];
        }
    } 
    // cout << l << r << d << u << endl;
    if (l > r || d > u) cout << 0 << endl;
    else cout << (r - l) * (u - d) << endl;
    return 0;
}

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll ans = a[0];
  dump(ans);
  for (int i = 1; i < N; i++) {
    ans = gcd(ans, a[i]);
    dump(ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,x,s[25],sum,ans,a[25][25],c[25];
int main()
{int i,j,k;
	scanf("%d%d%d",&n,&m,&x);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		for (j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
	 } 
	 ans=2e9;
	for (i=0;i<(1<<n);i++)
	{
		memset(s,0,sizeof(s));
		sum=0;
		for (j=0;j<n;j++)
		if ((i&(1<<j))!=0){
			for (k=1;k<=m;k++)
				s[k]+=a[j+1][k];
			sum+=c[j+1];
		}
		for (j=1;j<=m;j++)
		if (s[j]<x) break;
		if (j>m) ans=min(ans,sum);
	} 
	if (ans==2e9) printf("-1\n");
	else printf("%d",ans);
}

Measured memory_bytes: 3820
x = int(input())
count = 0

from math import sqrt

while count == 0:
  k = 0
  for i in range(1, x):
    if x % i == 0:
      k += 1
  if k == 1:
    print(x)
    count = 1
  else:
    if x % 2 == 0:
      x += 1
    else:
      x += 2

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

int main()
{
	int a[5],k;
	for(int i=0;i<5;++i)scanf("%d",&a[i]);
	scanf("%d",&k);
	int maxx=INT_MIN,minn=INT_MAX;
	 for(int i=0;i<5;++i){
	 	maxx=max(maxx,a[i]);
	 	minn=min(minn,a[i]);
	 }
	 if(maxx-minn<=k)printf("Yay!");
	 else printf(":(");
	 return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

void MaxHeapify(vector<int> &a, int x, int h) {
    int l = 2*x;
    int r = 2*x+1;
    int large;
    if(l <= h && a[x] < a[l]) large = l;
    else large = x;
    if(r <= h && a[large] < a[r]) large = r;

    if(x != large) {
        swap(a[x], a[large]);
        MaxHeapify(a, large, h);
    }
}

int main(){
    int h;
    cin >> h;
    V<int> a(h+1);
    Rep(i,h) cin >> a[i];
    for(int i = h/2; i >= 1; i--) {
        MaxHeapify(a,i,h);
    }
    Rep(i,h) cout << " " << a[i];
    cout << endl;
}


Measured memory_bytes: 4524
#include <iostream>
using namespace std;
const int maxn = 1e5 + 5;
int num[maxn];
int main()
{
	ios::sync_with_stdio(false);
	long long ans = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int a;
		cin >> a;
		ans += (a * 1LL);
		num[a]++;
	}
	int q;
	cin >> q;
	for (int i = 1; i <= q; i++)
	{
		int b, c;
		cin >> b >> c;
		int t = num[b];
		num[b] = 0;
		num[c] += t;
		ans += (c - b) * t * 1LL;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

const int N=4009;
const int md=924844033;

int n,k;
bool vis[N][N];
int ed[N],tot;
int f[N][N][2];
int g[N],fac[N];

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        for(int j=0;j<=1;j++)
            if(!vis[i][j])
            {
                int len=0;
                for(int x=i,y=j;x<=n;x+=k,y^=1)
                    vis[x][y]=1,++len;
                ed[tot+=len]=1;
            }

    f[1][0][0]=1;
    for(int i=1;i<=tot;i++)
        for(int j=0;j<=n;j++)
        {
            f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%md;
            if(!ed[i])
                f[i+1][j+1][1]=f[i][j][0];
        }

    for(int i=0;i<=n;i++)
        g[i]=(f[tot][i][0]+f[tot][i][1])%md;

    fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=(ll)fac[i-1]*i%md;

    int ans=fac[n];
    for(int i=1,j=-1;i<=n;i++,j=-j)
        ans=((ll)ans+md+(ll)j*fac[n-i]*g[i]%md)%md;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 136704
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int func(int a, int d){
  int k = 1;
  while ((k * a + 1) <= d){
    k++;
  }
  return k; 
}

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int ans = X;
  rep(i,N){
    int a;
    cin >> a;
    ans += func(a,D);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n;
	vector<bool> v(1001, false);
	cin >> n;
	v[1] = true;
	range(i, 2, 1000) {
		int t = i*i;
		while (t<=1000) {
			v[t] = true;
			t *= i;
		}
	}
	for (int i = n; i > 0; i--) {
		if (v[i]) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define N 100005
#define M 405
using namespace std;
bool bz[N];
int cd[M],rd[M],n,num,f[M],h,m,v1[M],v2[M];
int getf(int k)
{
	if(f[k]==k||!f[k]) return k;
	return (f[k]=getf(f[k]));
}
int main()
{
	cin>>n>>h;
	fo(i,1,n)
	{
		int a,b,c,d,x,y;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		x=(c>0)?c:(a+200);
		y=(d>0)?(d+200):b;
		cd[x]++,rd[y]++;
		int fx=getf(x),fy=getf(y);
		f[fx]=fy;
	}
	int w=0;
		bool pd=1;
		fo(i,1,400) 
		{
			if(rd[i]>0||cd[i]>0)
			{
				int fa=getf(i);
				if(rd[i]-cd[i]<0) 
				{
					v1[fa]++;
					if(i<=200)
					{
						pd=0;
						break;
					}
				}
				if(rd[i]-cd[i]>0) 
				{
					v2[fa]++;
					if(i>200)
					{
						pd=0;
						break;
					}
				}
			}
		}
		if(pd)
		fo(i,1,400)
		{
			if((rd[i]||cd[i])&&v1[getf(i)]==0) 
			{
				pd=0;
				break;
			}
		}
		if(pd) printf("YES\n");
		else printf("NO\n"); 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MAXN 100000
int a[MAXN + 1];
int main() {
    FILE * fi, * fout;
    int n, i;
    //fi = fopen("A.in" ,"r");
    //fout = fopen("A.out" ,"w");
    fi=stdin;
    fout=stdout;
    fscanf(fi,"%d" ,&n);
    int max = 0, cnt = 0;
    for(i = 1; i <= n; i++) {
       fscanf(fi,"%d" ,&a[i]);
       if(a[i] > max) {
          cnt = 1;
          max = a[i];
       }
       else if(max == a[i])
          cnt++;
    }
    std::sort(a + 1, a + n + 1);
    if(max - a[1] >= 2)
       fprintf(fout,"No\n");
    else {
       if(max == n - 1 && cnt == n)
          fprintf(fout,"Yes\n");
       else {
          if(cnt == 1)
             fprintf(fout,"No\n");
          else if(n - cnt + 1 <= max && max <= n - cnt + cnt / 2)
             fprintf(fout,"Yes\n");
          else
             fprintf(fout,"No\n");
       }
    }
    //fclose(fi);
    //fclose(fout);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string s,ss="CODEFESTIVAL2016";
int cnt;
int main()
{
	cin>>s;
	for(int i=0;i<16;++i)
	{
		if(s[i]!=ss[i])
			cnt++;
	}
	cout<<cnt;
	return 0;
}

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

#define VMAX 100000
#define WMAX 1000000000001L
using namespace std;

int main() {
  long W;
  long N;
  cin >> N;
  cin >> W;
  
  vector <long> wei(N);
  vector <long> val(N);
  for (int i = 0; i < N; ++i) {
    cin >> wei[i];
    cin >> val[i];
  }
  
  vector <vector <long> > dp(N, vector <long> (VMAX+1, WMAX));
  dp[0][0] = 0;
  dp[0][val[0]] = wei[0];
  for (int n = 1; n < N; ++n) {
    for (int v = 0; v <= VMAX; ++v) {
      if (v - val[n] >= 0) {
        dp[n][v] = min(dp[n - 1][v - val[n]] + wei[n], 
                       dp[n - 1][v]);
      } else {
        dp[n][v] = dp[n - 1][v];
      }
    }
  }
  
  for (long v = VMAX; v >= 0; --v) {
    if (dp[N - 1][v] <= W) {
      cout << v << endl;
      break;
    }
  }
      
  return 0;
}

Measured memory_bytes: 81996
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n,k;
cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    int dp[n+1]={0};
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    k=min(k,n);
    for(int i=2;i<k;i++)
    {dp[i]=INT_MAX;
        for(int j=0;j<i;j++)
        { dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));

        }
    }

    for(int i=k;i<n;i++)
    { dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }

    }


    cout<<dp[n-1]<<endl;

}


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

using namespace std;

int main() {
    int n,w;
    cin>>n>>w;
    int val[n], wt[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
        sum+=val[i];
    }
    
    long long int dp[sum+1];for(int i=1;i<=sum;i++) dp[i] = INT_MAX;
    dp[0]=0ll;
    
    for(int i=0;i<n;i++){
        for(int j=sum;j>=val[i];j--){
            dp[j]= min(dp[j], dp[j-val[i]]+wt[i]);
        }
    }
    
    for(int i=sum;i>=0;i--){
        if(dp[i]<=w){
            cout<<i<<"\n";
            break;
        }
    }
}

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

int main()
{
   long long a,b,n,x,y,m=0;
   cin>>a>>b>>n;
   if(n<b)
   {
       y=(a*n)/b;
       cout<<max(y,m)<<endl;
   }
  /* else if(n==b)
   {
       y=(a*(n-1))/b;
       cout<<max(y,m)<<endl;
   }*/
   else if(n>=b)
   {
       y=(a*(b-1))/b;
       /*x=(a*n)/b-a*(n/b);
       y=max(y,m);
       y=max(y,x);*/
       cout<<max(y,m)<<endl;
   }
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
	int N, R;
	scanf("%d%d",&N,&R);
	if(R>4111)
	{
		printf("second value must between 0-4111");
	}
	else if(N>=10)
	{
		printf("%d", R);
	}
	else
	{
		printf("%d", R+100*(10-N));
	}
	return 0;
}

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


int main() {
  int a, b;
  cin >> a >> b;
  if(a % 2 == 1 && b % 2 == 1){
    cout << "Odd";
  }
  else{
    cout << "Even";
  }
  return 0;
}




Measured memory_bytes: 3588