akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int x,n;
    cin>>x>>n;
    set<int> s;
    for(int i=0;i<n;i++) {
        int x;
        cin>>x;
        s.insert(x);
    }
    int ans = 1e9;
    int res=0;
    for(int i=-101;i<=101;i++) {
        if(s.count(i)) continue;
        if(ans>abs(x-i)) {
            ans = abs(x-i);
            res=i;
        }
    }
    cout<<res;
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main()
{
    int N;
    cin >> N;
    vector<pii> states[N];
    rep(i, 0, N)
    {
        int A;
        cin >> A;
        rep(j, 0, A)
        {
            int x, y;
            cin >> x >> y;
            --x;
            states[i].emplace_back(x, y);
        }
    }

    int cnt = 0;
    rep(status, 0, 1 << N)
    {
        if (cnt >= __builtin_popcount(status))
            continue;

        bool is_ok = true;
        rep(i, 0, N)
        {
            if (!((1 << i)&status)) continue;
            for (auto& state: states[i])
            {
                if (state.second^((status>>state.first) &1)) is_ok = false;
                if (!is_ok) break;
            }
            if (!is_ok) break;
        }
        if (is_ok)
            cnt = max(cnt, __builtin_popcount(status));
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  long H,W,m;
  cin >> H >> W >> m;
  vector<pair<long,long>> hw;
  vector<long> hi(3*100000+5),wi(3*100000+5);
  rep(i,int(hi.size())){
    hi[i] = 0;
    wi[i] = 0;
  }
  long h1,w1;
  rep(i,m){
    cin >> h1 >> w1;
    h1--;w1--;
    hw.push_back({h1,w1});
    hi[h1]++;
    wi[w1]++;
  }
  sort(hw.begin(), hw.end());
  long maxh = 0, maxw = 0, hzahyo = INF, wzahyo = INF;
  rep(i,hi.size())if(maxh < hi[i])maxh = hi[i];
  rep(i,wi.size())if(maxw < wi[i])maxw = wi[i];
  long ans = maxh + maxw;
  vector<int> hcan,wcan;
  rep(i,hi.size())if(maxh == hi[i]){
    hcan.push_back(i);
    hi[i] = -INF;
  }
  rep(i,wi.size())if(maxw == wi[i]){
    wcan.push_back(i);
    wi[i] = -INF;
  }
  long tmp = 0;
  rep(i,m){
    if(hi[hw[i].first]==-INF && wi[hw[i].second]==-INF){
      tmp++;
    }
  }
  if(tmp == int(hcan.size())*int(wcan.size()))ans--;
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

int main() {
    //ios::sync_with_stdio(0);
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 3632
n = int(input())
x = list(map(int, input().split()))

import numpy as np
ary = np.array(x)
ranks = ary.argsort()
rank_dict = {index:rank for rank,index in enumerate(ranks, start=1)}

MID=n//2
upper = x[ranks[MID]]
lower = x[ranks[MID-1]]
for i in range(n):
    rank = rank_dict[i]
    if rank <= MID:
        print(upper)
    else:
        print(lower)

Measured memory_bytes: 52324
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1005;
int Notprime[MAXN * 100], Prime[MAXN * 100], tot;
LL a[MAXN][MAXN];

void Euler(int Max) {
  for (RI i = 2; i <= Max; ++i) {
    if (!Notprime[i]) Prime[++tot] = i;
    for (RI j = 1; j <= tot && i * Prime[j] <= Max; ++j) {
      Notprime[i * Prime[j]] = 1;
      if (i % Prime[j] == 0) break;
    }
  }
}
inline LL lcm(LL x, LL y) {
  if (!x || !y) return x | y;
  return x / __gcd(x, y) * y;
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  Euler(100000);
  if (n == 2) return puts("4 7\n23 10"), 0;
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= n; ++j)
      if ((i + j) & 1)
        a[i][j] = 1ll * Prime[(i + j) >> 1] * Prime[(i - j + n + 1) / 2 + n - 1];
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= n; ++j)
      if (!((i + j) & 1))
        a[i][j] = lcm(lcm(a[i - 1][j], a[i + 1][j]), lcm(a[i][j - 1], a[i][j + 1])) + 1;
  for (RI i = 1; i <= n; ++i, puts(""))
    for (RI j = 1; j <= n; ++j)
      printf("%lld ", a[i][j]);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

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

typedef long long ll;

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------

	int N; cin >> N;
	int A[60], B[60], C[60];

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}
	for (int i = 0; i < N-1; i++)
	{
		cin >> C[i];
	}
	
	int ans = 0;

	ans += B[A[0] - 1];

	for (int i = 1; i < N; i++)
	{
		ans += B[A[i] - 1];
		if (A[i] - A[i-1] == 1)
		{
			ans += C[A[i-1] - 1];
		}
		
	}
	
	cout << ans << "\n";
}

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(n,0);
    int sum = 0;
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        a[k]++;
    }
    for(int i=0;i<=x;i++){
        if(a[i]==1) sum++;
    }
    cout << min(sum,m-sum) << endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().strip().split()))
res = 0

for k in range(2, N):
    for j in range(1, k):
        if L[k] == L[j]:
            continue
        for i in range(0, j):
            if L[i] == L[j]:
                continue
            if L[k] == L[i]:
                continue
            if L[i] + L[k] <= L[j]:
                continue
            if L[i] + L[j] <= L[k]:
                continue
            if L[j] + L[k] <= L[i]:
                continue
            res += 1

print(res)


Measured memory_bytes: 9200
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

const int maxn = 300100;
const int maxm = 100100;

struct edge{int l,r;}a[maxn];
int n,m;
int c[maxn];

void modify(int l,int r,int x){
	//printf("%d %d\n",l,r);
	c[l]+=x,c[r+1]-=x;
}

int main(){
	n=read(),m=read();
	//c[1]+=n;
	for(int i=1;i<=n;i++)
		a[i].l=read(),a[i].r=read();
	for(int i=1;i<=n;i++){
		int l=a[i].l,r=a[i].r;
		int block=sqrt(r);
		//printf("->>>>>%d %d %d\n",l,r,block);
		int x=0,last=0x7f7f7f7f;
		for(int j=1;j<=block;j++){
			int sl=l/j,sr=r/j;
			if(sl&&l%j) sl++;
			sr = min(last,sr);
			if(sl&&sl<=sr) modify(sl,sr,1);
			if(j==block) x=sl-1;
			last = sl-1;
		}
		int sb=r/block;
		for(int j=1;j<=min(sb,x);j++)
			if((l%j==0)||l/j<r/j) modify(j,j,1);
	}
	for(int i=1;i<=m;i++) c[i]+=c[i-1];
	for(int i=1;i<=m;i++)
		printf("%d\n",c[i]);
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 51;
int n, a[N], b[N];
vector <int> have;
bool dp[N];
bool check(int u, int v, int mx) {
    memset(dp, 0, sizeof dp);
    dp[u] = 1;
    for (int m : have) for (int i = 0; i < N; ++i) dp[i % m] |= dp[i];
    for (int m = mx; m; --m) for (int i = 0; i < N; ++i) dp[i % m] |= dp[i];
    return dp[v];
}   
bool check(int mx) {
    for (int i = 0; i < n; ++i) if (!check(a[i], b[i], mx)) return 0;
    return 1;
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    if (!check(N - 1)) {
        cout << "-1\n";
        exit(0);
    }   
    int ans = 0;
    for (int i = N - 1; i; --i) {
        if (!check(i - 1)) {
            ans += 1ll << i;
            have.app(i);
        }   
    }   
    cout << ans << '\n';
}   

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


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



int main() {

	// TODO: streamやめる

	cin.tie(0); ios::sync_with_stdio(false);

	INPUT_LLINT(N);
	INPUT_VECTOR_INT(A, N);

	long long int x = 1;
	long long int y = 0;
	long long int z = 0;

	long long int ans = 3;

	if (A[0] != 0) {
		OUTPUT(0);
		return 0;
	}

	for (long long int i = 1; i < N; ++i) {

		long long int a = A[i];

		long long int con = (a == x ? 1 : 0) + (a == y ? 1 : 0) + (a == z ? 1 : 0);

		if (con == 0) {
			OUTPUT(0);
			return 0;
		}
		ans = mod_mul<(long long int)1000000007>(ans, con);

		if (a == x) { ++x; }
		else if (a == y) { ++y; }
		else { ++z; }

	}

	OUTPUT(ans);

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x)
{
  while( x->left != NIL ) 
    x = x->left;
  return x;
}
Node treeMaximum(Node x)
{
  while( x->right != NIL ) 
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k)
{
  while( u != NIL && k != u->key )
  {
    if ( k < u->key ) 
      u = u->left;
    else 
      u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x)
{
  if ( x->right != NIL ) 
    return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right )
  {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) 
    y = z;
  else 
    y = treeSuccessor(z);
  if ( y->left != NIL ) 
    x = y->left;
  else 
    x = y->right;

  if ( x != NIL ) 
    x->parent = y->parent;

  if ( y->parent == NIL )
    root = x;
  else 
  {
    if (y == y->parent->left) 
      y->parent->left = x;
    else 
      y->parent->right = x;
  }

  if ( y != z )
    z->key = y->key;
  free(y);
}

void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL )
  {
    y = x;
    if ( z->key < x->key )
      x = x->left;
    else 
      x = x->right;
  }

  z->parent = y;
  if ( y == NIL )
    root = z;
  else 
  {
    if (z->key < y->key) 
      y->left = z;
    else 
      y->right = z;
  }
}

void inorder(Node u)
{
  if ( u == NIL ) 
    return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u)
{
  if ( u == NIL ) 
    return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
  {
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 )
    {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( strcmp(com, "findMin") == 0 )
      {
	      Node minn = treeMinimum(t);
	      printf("%d\n", minn->key);
      } 
      else if ( strcmp(com, "findMax") == 0 )
      {
	      Node maxn = treeMaximum(t);
	      printf("%d\n", maxn->key);
      } 
      else 
      {
	      if ( t != NIL ) 
          printf("yes\n");
	      else 
          printf("no\n");
      }
    } 
    else if ( com[0] == 'i' )
    {
      scanf("%d", &x);
      insert(x);
    } 
    else if ( strcmp(com, "print") == 0 )
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
    else if ( strcmp(com, "delete") == 0 )
    {
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}




Measured memory_bytes: 20536
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int a = 0; a * 4 <= n; ++a) {
    int r = n - 4 * a;
    if (r % 7 == 0) {
      int b = r / 7;
      if (b >= 0) {
        cout << "Yes" << '\n';
        return 0;
      }
    }
  } 
  cout << "No" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<math.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int binary(int bina){
  int ans = 0;
  for (int i = 0; bina>0 ; i++)
  {
    ans = ans+(bina%2)*pow(10,i);
    bina = bina/2;
  }
  return ans;
}

int main() {
  int N, a[200005];
  int total_xor = 0;
  cin >> N;
  rep(i,N) {
    cin >> a[i];
    total_xor ^= a[i];
  }
  rep(i,N) {
    if (i == N - 1) {
      cout << (a[i]^total_xor) << endl;
      return 0;
    }
    cout << (a[i]^total_xor) << ' ';
  }
  return 1;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;



int main() {
    int N,K; cin >> N >> K;
    vector<char> D(K);
    REP(i,K) cin >> D[i];
    FOR(i,N,100000){
        string s = to_string(i);
        bool ok = true;
        REP(j,s.size()){
            REP(k,K){
                if(D[k]==s[j]) ok = false;
            }
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>>a(m),b(m);
    for(int i=0;i<m;i++){
        int z,zz;
        cin >> z >> zz;
        a.at(i)=make_pair(z,zz);
        b.at(i)=a.at(i);
    }
    map<string,string>ma;
    string zero = "000000000000000";
    sort(a.begin(),a.end());
    int now = 1,mae =-100;
    for(int i=0;i<m;i++){
        string l = "",r="";
       string af = to_string(a.at(i).first),as=to_string(a.at(i).second);
        if(af.size()<6){
            l = zero.substr(0,6-af.size());
        }
        l+=af;
        if(mae==a.at(i).first){
            string d = to_string(now);
            now++;
            if(d.size()<6){
                r=zero.substr(0,6-d.size());
            }
            r+=d;
        }
        else {
            now = 2;
            mae = a.at(i).first;
            r ="000001";
        }
        af+=as;
        l+=r;
        ma[af]=l;
    }
    for(int i=0;i<m;i++){
     string af = to_string(b.at(i).first),as=to_string(b.at(i).second);
     af+=as;
     cout<< ma.at(af)<<endl;        
    }
}


Measured memory_bytes: 20480
h, w = map(int, input().split())
a = [list(map(int,input().split())) for i in range(h)]

ans = cnt = 0
arr = []
for i in range(h):
        if i%2:
                for j in range(w-1, -1, -1):
                        cnt += 1
                        if cnt==h*w: break
                        if a[i][j]%2:
                                ans += 1
                                if j==0:
                                        arr.append([i+1, j+1, i+2, j+1])
                                        a[i][j] -= 1
                                        a[i+1][j] += 1
                                else:
                                        arr.append([i+1, j+1, i+1, j])
                                        a[i][j] -= 1
                                        a[i][j-1] += 1
        else:
                for j in range(w):
                        cnt += 1
                        if cnt==h*w: break
                        if a[i][j]%2:
                                ans += 1
                                if j==w-1:
                                        arr.append([i+1, j+1, i+2, j+1])
                                        a[i][j] -= 1
                                        a[i+1][j] += 1
                                else:
                                        arr.append([i+1, j+1, i+1, j+2])
                                        a[i][j] -= 1
                                        a[i][j+1] += 1
print(ans)
for i in arr: print(*i)

Measured memory_bytes: 30288
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){
  vector<int>num;
  vector<int>su;
  int n,s;
  int co=0;
  char d;
  while(cin>>n>>d>>s,n||s){
    co++;
    pb(num,s);
    pb(su,n);
  }
  rep(i,co){
    rep(j,co-1){
      if(num[j]<num[j+1]){
	swap(num[j],num[j+1]);
	swap(su[j],su[j+1]);
      }
    }
  }
  //rep(i,co)
    //cout<<num[i]<<endl;

  int tmp=num[0];
  num[0]=1;
  int count=1;
  loop(i,1,co){
    if(tmp!=num[i])count++;
    tmp=num[i];
    num[i]=count;
  }
  //rep(i,co)
    //cout<<num[i]<<endl;

  int in;
  while(cin>>in){
    int i;
    for(i=0;i<co;i++)if(su[i]==in)break;
    cout<<num[i]<<endl;
  }


}

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

int main(){
    /*double a=(2+sqrt(2))*2/3;
    cout << a << endl;*/
    int i,j,n=0;
    double dist=0;
    cin >> n;
    vector<vector<int>> x(n,vector<int>(2));
    for(i=0;i<n;i++){
        cin >> x.at(i).at(0) >> x.at(i).at(1);
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            dist += sqrt((x.at(j).at(0)-x.at(i).at(0))*(x.at(j).at(0)-x.at(i).at(0))+(x.at(j).at(1)-x.at(i).at(1))*(x.at(j).at(1)-x.at(i).at(1)));
        }
    }
    dist = dist*2/n;
    printf("%.12f\n",dist);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define aint(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          int;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD = 1000000007;

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

signed main(){
	string s;
	cin >> s;
	for(int i = 0;i < 3;i++){
		if(s[i] == '1') s[i] = '9';
		else s[i] = '1';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    vec cnt(N, 0);
    REP(i, N) cnt[A[i] - 1]++;
    Sort(cnt);
    vec S(N + 1, 0);
    REP(i, N) S[i + 1] = S[i] + cnt[i];

    vec F(N + 2);
    FOR(x, 1, N + 1){
        int i = Upper_bound(cnt, x);
        F[x] = (S[i] + x * (N - i)) / x;
    }
    F[N + 1] = 0;

    vec ans(N + 1, 0);
    FOR(x, 1, N + 1){
        FOR(k, F[x + 1] + 1, F[x] + 1) ans[k] = x;
    }

    FOR(i, 1, N + 1) Out(ans[i]);

    return 0;
}


Measured memory_bytes: 12544
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

def main():
    a, b = map(int, input().split())
    if a <= 0 <= b:
        print("Zero")
    elif 0 < a:
        print("Positive")
    elif (a - b) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
H,W = list(map(int, input().split()))
S = [[0 if s=='#' else 1 for s in input()] for _ in range(H)] #S[h][w]

SH = [[0]*W for _ in range(H)]
SH_ = [[0]*W for _ in range(H)]

SV = [[0]*W for _ in range(H)]
SV_ = [[0]*W for _ in range(H)]

#horizontal
for h in range(H):
  SH[h][0] = S[h][0]
  for w in range(1,W):
    if S[h][w]:
      SH[h][w] = SH[h][w-1] + 1
  
  SH_[h][-1] = S[h][-1]
  for w in range(W-1)[::-1]:
    if S[h][w]:
      SH_[h][w] = SH_[h][w+1] + 1
  

#vertical
for w in range(W):
  SV[0][w] = S[0][w]
  for h in range(1,H):
    if S[h][w]:
      SV[h][w] = SV[h-1][w] + 1
  
  SV_[-1][w] = S[-1][w]
  for h in range(H-1)[::-1]:
    if S[h][w]:
      SV_[h][w] = SV_[h+1][w] + 1

#print(SH + SH_)
#print(SV + SV_)

ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans, SH[h][w] + SH_[h][w] + SV[h][w] + SV_[h][w] -3)

print(ans)


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

int main()
{
  int N,X;
  int m[1000];
  int min=99999;
  int sum=0;
  int count=0;

  cin >> N >> X;
  for (int i=0;i<N;i++){
    cin >> m[i];
  }
  for (int i=0;i<N;i++){
    if(min > m[i]){
      min = m[i];
    }
    sum+=m[i];
    count++;
  }
  while(true){
    if(sum + min > X ){
      break;
    }
    sum+=min;
    count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int a, b, d, X, Y, x, y;

int extgcd(int a, int b, int &x, int &y){
  int d = a;
  if(b){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1;
    y = 0;
  }
  return d;
}

void change_ans(){
  if(abs(x) + abs(y) < X + Y){
    X = abs(x);
    Y = abs(y);
  }else if(abs(x) + abs(y) == X + Y && a*abs(x) + b*abs(y) < a*abs(X) + b*abs(Y)){
    X = abs(x);
    Y = abs(y);
  }
}



int main(){
  while(cin >> a >> b >> d, a){
    int g = extgcd(a,b,x,y), r = d/g;
    x *= r; y *= r;
    a /= g;
    b /= g;
    X = abs(x);
    Y = abs(y);
    if(x <= 0){
      int x_ = (b - (-x)%b)%b;
      int t = (x_ - x) / b;
      y -= t*a;
      x = x_;
      change_ans();
      x -= b;
      y += a;
      change_ans();
      x += b;
      y -= a;
    }
    if(y <= 0){
      int y_ = (a - (-y)%a)%a;
      int t = (y_ - y) / a;
      x -= t*b;
      y = y_;
      change_ans();
      x += b;
      y -= a;
      change_ans();
      x -= b;
      y += a;
    }
    if(x >= 0){
      int x_ = x%b;
      int t = x / b;
      y += t*a;
      x = x_;
      change_ans();
      x -= b;
      y += a;
      change_ans();
      x += b;
      y -= a;
    }
    if(y >= 0){
      int y_ = y%a;
      int t = y / a;
      x += t*b;
      y = y_;
      change_ans();
      x += b;
      y -= a;
      change_ans();
      x -= b;
      y += a;
    }
    cout << X << " " << Y << endl;
  }
  return 0;
}

Measured memory_bytes: 2960
a,b,c = map(int,input().split())
if 1<=a<=10000 and 1<=b<=10000 and 1<=c<=10000:
    if a >= b:
        if b>=c:
            print(c,b,a)
        elif a >=c and b<=c:
            print(b,c,a)
        else:
            print(b,a,c)
    else:
        if b <= c:
            print(a,b,c)
        elif a<=c and b>=c:
            print(a,c,b)
        else:
            print(c,a,b)


Measured memory_bytes: 5596
// Problem Statement
// Given is a positive integer N
// Find the number of pairs
// (A,B) of positive integers not greater than N hat satisfy the following condition:
// When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of
// A is equal to the last digit of B.

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return res;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    ll n;
    cin >> n;
    ll b = log2(n) + 1;
    cout << fast_exp(2, b) - 1;
}


Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int main(){
	int N, Q;
	char S[100001];
	cin >> N >> Q >> S;

	int answers[100000];
	int counter = 0;
	for (int i = 1; i < N; i++){
		if (S[i - 1] == 'A' && S[i] == 'C'){
			counter++;
		}

		answers[i] = counter;
	}

	int l, r;
	for (int q = 0; q < Q; q++){
		cin >> l >> r;
		cout << answers[r-1] - answers[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
alist = list(sorted(d.keys(), reverse = True))
amax = alist[0]
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
for a in alist:
  if a not in d:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  while True:
    if t not in d:
      break
    if a == t and d[a] == 1:
      break
    result += 1
    if d[a] == 1:
      del d[a]
    else:
      d[a] -= 1
    if d[t] == 1:
      del d[t]
    else:
      d[t] -= 1
    if a not in d:
      break
print(result)


Measured memory_bytes: 44684
#include <stdio.h>

int main()
{
    int n, i, a[10000], max, min;
    long int sum = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d ", &a[i]);
    }

    max = a[0];
    min = a[0];
    for(i = 0; i < n; i++){
        sum = sum + a[i];
        if(a[i] >= max){
            max = a[i];
        }else if(a[i] <= min){
            min = a[i];
        }
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}

Measured memory_bytes: 644
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1''などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline




def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = MOD #出力の制限
N = 5*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N,M,K = MI()
ans = 0
for i in range(0,K+1):
    ans += (cmb(N-1,i,mod)*M*pow(M-1,N-1-i,mod))%mod
print(ans%mod)


Measured memory_bytes: 168016
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll delta = abs(a - b);
  if (delta % 2 == 0) {
    cout << delta / 2;
  } else {
    ll p = min(a, b);
    ll q = max(a, b);
    ll ans = min(q - 1, n - p);
    ans = min(ans, p + (q - p - 1) / 2);
    ans = min(ans, n - q + 1 + (q - p - 1) / 2);
    cout << ans;
  }
}

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

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

const int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin();
    vector<int> As(N);
    int nonNegaNum = 0;
    for (auto &Ai : As)
    {
        Ai = Cin();
        if (Ai >= 0) ++nonNegaNum;
    }
    sort(As.begin(), As.end());
    int ans = 0;
    // 負の数が１つもない場合，最小の数A0で引かれるようにする
    // すなわち，A_{N-1}-(A0-A1-...-A_{N-2})とすればよい
    if (nonNegaNum == N)
    {
        ans = As[0];
        for (int i = 1; i < N - 1; ++i) ans -= As[i];
        ans = As[N - 1] - ans;
        cout << ans << endl;
        int prev = As[0];
        for (int i = 1; i <= N - 2; ++i)
        {
            cout << prev << ' ' << As[i] << endl;
            prev -= As[i];
        }
        cout << As[N - 1] << ' ' << prev << endl;
    }
    // 全て負の数のとき，A_{N-1}からそれ以下の数を全て引けば良い
    // すなわち，A_{N-1}-A0-A1-...-A_{N-2}とすればよい
    else if (nonNegaNum == 0)
    {
        ans = As[N - 1];
        for (int i = 0; i <= N - 2; ++i) ans -= As[i];
        cout << ans << endl;
        int prev = As[N - 1];
        for (int i = 0; i <= N - 2; ++i)
        {
            cout << prev << ' ' << As[i] << endl;
            prev -= As[i];
        }
    }
    // ゼロ以上の数がk=(nonNegaNum)個のとき，
    // A0,A1~A_{N-k-1}(={-})が負の数で，A_{N-k}~A_{N-2}(={+}),A_{N-1}がゼロ以上の数
    // このとき，A_{N-1}-(A0-{+})-{-}=A_{N-1}+{+}-{-}-A0とすれば全て正にできて最大
    else
    {
        for (const int &Ai : As) ans += abs(Ai);
        cout << ans << endl;
        int prev = As[0];
        for (int i = N - nonNegaNum; i <= N - 2; ++i)
        {
            cout << prev << ' ' << As[i] << endl;
            prev -= As[i];
        }
        cout << As[N - 1] << ' ' << prev << endl;
        prev = As[N - 1] - prev;
        for (int i = 1; i <= N - nonNegaNum - 1; ++i)
        {
            cout << prev << ' ' << As[i] << endl;
            prev -= As[i];
        }
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
const int inf = 1e9;
int main(){
    ll n, w; 
    cin >> n >> w;
    vector<vector<ll> > dp(n+1, vector<ll>(w+1, 0));
    vector<ll> val(n), wei(n);
    rep(i,n) cin >> wei[i] >> val[i];
    rep(i,w+1)dp[0][i] = 0;
    rep(i,n)rep(j,w+1){
        dp[i+1][j] = dp[i][j];
        if(j >= wei[i])dp[i+1][j] = max(dp[i][j], dp[i][j-wei[i]] + val[i]);
    }
    cout << dp[n][w] << endl;
    
    //rep(i,n+1)rep(j,w+1)cout << dp[i][j] << ((j < w)?" ":"\n");
    return 0;
}

Measured memory_bytes: 80256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
cnt = Counter(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    s += (c - b)*cnt[b]
    cnt[b], cnt[c] = 0, cnt[c] + cnt[b]
    print(s)

Measured memory_bytes: 23960
N = gets.to_i
arr = gets.split.map.with_index{|a, id| a.to_i - (id + 1)}.sort
pivot = arr[N/2]
def abs(n)
  n > 0 ? n : -n
end
ans = 0
N.times do |i|
  ans += abs(arr[i]-pivot)
end
puts ans


Measured memory_bytes: 19072
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 999999999
typedef long long ll;

using namespace std;

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

int main(void){
	int n, m;
	cin >> n >> m;
	cout << (int) pow(2.0, m) * (100*(n-m) + 1900*m) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+10;
typedef long long ll;
ll a[M];
int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	ll ans=0;
	for(int i=1;i<=n-k;i++)ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
// contest.go
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s1 string
	var s2 string
	var rev string
	s1 = nextLine()
	s2 = nextLine()
	rev = reverse(s1)
	if s2 == rev {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func reverse(s string) string {
	ans := ""
	for i, _ := range s {
		ans += string(s[len(s)-i-1])
	}
	return string(ans)
}


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

int main() {
  ll N, K;
  cin >> N >> K;
  
  ll C=1, ans=1;
  while(1){
    if(C <= N && N < C*K){
      break;
    }
    C *= K;
    ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a - b * 2) << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i

S = []

N.times do 
  S << gets.chomp
end

memo = {}

S.each do |s|
  if !memo[s] then
    memo[s] = 0
  end
  memo[s] += 1
end

list = memo.sort{|a, b| b[1] <=> a[1]}
list = list.select{|a| a[1] == list[0][1]}

out = ""
out = list.each.map{|a| a[0]}.sort().join("\n")

puts out

Measured memory_bytes: 56552
#include<stdio.h>
int main()
{
    int n,i,j,count=0;
    scanf("%d",&n);
    for(i=1;i<=9;i++)
    {
    for(j=9;j>=1;j--)
    {
        if((i*j)==n)
            count++;

    }
    }
    if(count>0)
        printf("Yes");
    else printf("No");

    return 0;
}

Measured memory_bytes: 128
N = gets.to_i - 1
H = gets.split.map(&:to_i)

c = 0

(0..N).each do |l|
    while H[l] != 0 do
        for r in (l..N)
            if H[r] >= 1
                H[r] -= 1
            else
                break
            end
        end
        c += 1
    end
end

puts c


Measured memory_bytes: 3836
#include<iostream>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main()
{
 double x1, y1, x2, y2, x3, y3, xp, yp, a, b, c;
 while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
 {
     a = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
     b = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
     c = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
     
     if((a>0 && b>0 && c>0)||(a<0 && b<0 && c<0))
         cout<<"YES"<<endl;
     else
         cout<<"NO"<<endl;
 }
 return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
int main()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
    }

    vector<ll> dp(n, 0);
    vector<int> pos(1e6);
    for(int i = 0; i < 1e6; i++)
    {
        pos[i] = -1;
    }
    pos[c[0]] = 0;
    dp[0] = 1;
    for(int i = 1; i < n; i++)
    {
        dp[i] = dp[i-1];
        int bpos = pos[c[i]];
        if(bpos != -1 && bpos != i-1)
        {
            dp[i] = (dp[i] + dp[bpos]) % MOD;
        }
        pos[c[i]] = i;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define INF 1 << 30
#define mod 1000000007
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define dLoop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

void Swap(ll*a,int x,int y){ll t=a[x];a[x]=a[y];a[y]=t;}
void Qsort(ll*n,int l,int r){if(l>=r)return;int i=l-1,j=r+1;ll m=n[(i+j)/2];
    while(1){while(n[++i]<m);while(n[--j]>m);if(i>=j)break;Swap(n,i,j);}
	Qsort(n,l,i-1);Qsort(n,j+1,r);}
	
	

int main() {

	ACCEL

	int n, m;
	while ( cin >> n >> m ) {
		int fav[ m+5 ]; memset( fav, 0, sizeof (fav) );
		
		Loop ( i, 1, n) {
			int k; cin >> k;
			Loop ( i, 1, k) {
				int f; cin >> f; fav[ f ]++ ;
			}
		}
		
		ll ans = 0;
		
		Loop ( i, 1, m) {
			if ( fav[ i ] == n ) {
				ans++ ;
			}
		}
		
		cout << ans << '\n';
	}
	return 0;
}











Measured memory_bytes: 256
#include<stdio.h>

int max(int a,int b){
  if(a>b) return a;
  return b;
}
int min(int a,int b){
  if(a<b) return a;
  return b;
}

int main(){
  int i,n,R[200000],maxv,minv;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&R[i]);
  maxv=-2000000000;
  minv=R[0];
  for(i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }
  printf("%d\n",maxv);
  return 0;
}



Measured memory_bytes: 2524
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, A, B, P[110];
	cin >> N >> A >> B;
	int count[3] = { 0 };
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		if (P[i] <= A)count[0]++;
		else if (P[i] > B) count[2]++;
		else count[1]++;
	}
	cout << min({ count[0],count[1],count[2] }) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define len 100003
typedef struct{
    char na[10];
    int t;
}P;

P Q[len];
int head,tail;
void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%len;
    
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%len;
    return x;
}
int laps;

int main(){
    int n,q;
    scanf("%d %d",&n,&q);
    head=0,tail=n;
    int i;
    for(i=0;i<=n-1;i++){
        scanf("%s",Q[i].na);
        scanf("%d",&Q[i].t);
    }
    P u;
    while(head!=tail){
        u=dequeue();
        if(u.t>q){
            u.t-=q;
            laps+=q;
            enqueue(u);
        }else{
            laps+=u.t;
            printf("%s %d\n",u.na,laps);
        }
    }
    return 0;
}



Measured memory_bytes: 3284