akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second


struct timet{
  std::vector<std::chrono::system_clock::time_point> tp;
  timet(){
    tp = std::vector<std::chrono::system_clock::time_point>(10);
  }
  timet(int n) {
    tp = std::vector<std::chrono::system_clock::time_point>(n);
  }
  void recordtime(int x){
    tp[x] = std::chrono::system_clock::now();
  }
  int caltime(int x, int y, int option = 0){
    return std::chrono::duration_cast<std::chrono::milliseconds>(tp[y] - tp[x]).count();
  }
};



template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;


void solve(){
  timet tm(5);
  tm.recordtime(0);
  int n; cin >> n;
  V2<int> a(n, V<int>(n));
  FOR(i,0,n) FOR(j,0,n-1) {cin >> a[i][j]; a[i][j]--;}
  int l = 0, r = n*(n-1)/2+10, m;
  bool tle = false;
  while(r-l>1){
    m = (l+r)>>1;
    bool psbl = true;
    [&](){
      V<int> mat(n,0);
      FOR(i,0,m){
        tm.recordtime(1);
        if(tm.caltime(0,1)>1000) {tle = true; return;}
        V<bool> b(n,false);
        bool flg = false;
        FOR(j,0,n){
          if(b[j]) continue;
          if(mat[j]>n-1) continue;
          int comt = a[j][mat[j]];
          if(!b[comt] && a[comt][mat[comt]]==j){
            b[comt] = true;
            b[j] = true;
            mat[comt]++;
            mat[j]++;
            flg = true;
          }
        }
        if(!flg) break;
      }
      FOR(i,0,n) if(mat[i]<n-1) { psbl = false; return;}
      return;
    }();
    if(psbl) r = m;
    else l = m;
    if(tle) {cout << (ll)n*(n-1)/2; return;}
  }
  if(r>n*(n-1)/2+2) cout << -1 << '\n';
  else cout << r << '\n';
}

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

Measured memory_bytes: 4224
S = str(input())
ans = [0] * 13
ans[0] = 1
MOD = 10**9 + 7
for i in S:
    dp = [0] * 13
    for j in range(13):
        dp[(j * 10) % 13] = ans[j] % MOD
    dp += dp
    if i == '?':
        for j in range(13):
            ans[j] = sum(dp[j+4:j+14])
    else:
        for j in range(13):
            ans[j] = dp[j + 13 - int(i)]
print(ans[5] % MOD)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define vll vector<ll>
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define line "\n"
#define mav(a) (*max_element(ALL(a)))
#define miv(a) (*min_element(ALL(a)))
#define vfind(a,n) (find(ALL(a),n)-a.begin())
#define prque priority_queue
#define MOD 1000000007ll
using namespace std;
void solve();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

//nCk(mod p)
/*ll fac[510000], finv[510000], inv[510000];
void cmodf(ll p = MOD) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, 510000) {
		fac[i] = fac[i - 1] * i%p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i - 1] * inv[i] % p;
	}
}
ll cmod(ll n, ll k, ll p = MOD) {
	return fac[n] * (finv[k] * finv[n - k] % p) % p;
}*/

//最大公約数
ll gcd(ll n, ll m) {
	ll k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return m;
}
ll gcd(vector<ll> a) {
	rep(i, 1, a.size()) {
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(ll n, ll m) {
	ll t = n * m, k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return t / m;
}
ll lcm(vector<ll> a) {
	ll n;
	rep(i, 1, a.size()) {
		n = a[i - 1] * a[i];
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
		n /= a[i];
		a[i] = n;
	}
	return n;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key) {
	/*変更*/
	return 0;
}
ll mini(ll lkey, ll rkey/*ここも調べる*/, ll joken) {
	ll mkey;
	while (lkey != rkey) {
		mkey = (lkey + rkey) / 2;
		if (value(mkey) >= joken)rkey = mkey;
		else lkey = mkey + 1;
	}
	return rkey;
}

//ペア配列の整理
struct pea { ll n, m; };
void msort(vector<pea> &a, bool k = true) {
	struct hikakukansu {
		static bool unstable(const pea &x, const pea &y) { return x.m < y.m; }
		static bool stable(const pea &x, const pea &y) { return (x.m == y.m ? x.n < y.n : x.m < y.m); }
	};
	if (k)sort(ALL(a), hikakukansu::unstable);
	else sort(ALL(a), hikakukansu::stable);
}

//変数定義

//再帰関数

//アルゴリズム
void solve() {
	string s;
	prque<ll> a;
	while (cin >> s) {
		if (s == "insert") {
			ll n; cin >> n;
			a.push(n);
		}
		else if (s == "extract") {
			cout << a.top() << endl;
			a.pop();
		}
		else break;
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int ans = 0;
  for (int i=0; i<N; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  //for (int i=0; i<N; i++) cout << vec.at(i) << endl;
  for (int a=0; a<N; a++) {
    int aa = vec.at(a);
    for (int b=a+1; b<N; b++) {
      int bb = vec.at(b);
      for (int c=b+1; c<N; c++) {
        int cc = vec.at(c);
        if ((aa < bb) && (bb < cc)) {
          if (cc < (aa + bb)) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define pob pop_back();
#define for_t int t;cin>>t;while(t--)
#define MOD 1000000007
#define fi first
#define se second
#define le length
#define debug(n1) cout << n1 << endl
#define set_bits(n) __builtin_popcount(n);
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef map<int, int>mapp;
 
int stoif(string num){
    stringstream geek(num);
    int x = 0; 
    geek >> x; 
    return x;
}   
 
int main() {
    SPEED;
    int n;
    cin>>n;
    int ans = n*n*n;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    deque<char> deq;
    int n = s.size();
    for(int i = 0; i < n; i++){
        deq.push_back(s[i]);
    }
    int q;
    cin >> q;
    bool rev = false;
    for(int i = 0; i < q; i++){
        int t;
        cin >> t;
        if(t == 1 && !rev) rev = true;
        else if(t == 1) rev = false;
        else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(f == 2 && !rev) deq.push_back(c);
            else if(f == 2) deq.push_front(c);
            else if(f == 1 && rev) deq.push_back(c);
            else deq.push_front(c);
        }
    }
    while(!deq.empty()){
        if(!rev){
            cout << deq.front();
            deq.pop_front();
        } else {
            cout << deq.back();
            deq.pop_back();
        } 
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>

int main(void){
	int d,n;
	scanf("%d%d", &d, &n);
	long long ans=0;
	if(d == 0){
        if(n==100){
          n +=1;
        }
		printf("%d\n",n);
	}
	else if(d == 1){
		ans= n * 100;
		if(n==100){
			ans += 100;
		}
		printf("%lld\n", ans);
	}
	else {
		ans = n * 10000;
		if(n==100){
			ans += 10000;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define EPS     1e-11
#define INF     0x7fffffff
#define LL_INF  0x7fffffffffffffff

typedef long long LL;
struct Point {
        int x, y;
};
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};


int main() {
    int n;
    vector<string> v;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (find(v.begin(), v.end(), s) != v.end()) {
            cout << "No" << endl;
            return 0;
        }
        if (i > 0 && v[i-1].substr(v[i-1].size() - 1) != s.substr(0, 1)) {
            cout << "No" << endl;
            return 0;
        }
        v.push_back(s);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,A[100][100],color[100],d[100],f[100],time;

void visit(u){
  int v;

  color[u] = GRAY;
  d[u] = ++time;
  for(v = 0;v < n;v++){
    if(A[u][v] == 0) continue;
    if(color[v] == WHITE) visit(v);
  }
  color[u] = BLACK;
  f[u] = ++time;
}

void dfs(){
  int u;
  
  for(u = 0;u < n;u++){
    color[u] = WHITE;
  }
  time = 0;

  for(u = 0;u < n;u++){
    if(color[u] == WHITE) visit(u);
  }
  for(u = 0;u < n;u++){
    printf("%d %d %d\n",u + 1,d[u],f[u]);
  }
}



int main()
{
  int i,j,k,u,v;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++) A[i][j] = 0;
  }

  for(i = 0;i < n;i++)
    {
      scanf("%d%d",&u,&k);
      u--;
      for(j = 0;j < k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  A[u][v] = 1;
	}
    }

  dfs();

  return 0;
}



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

int main() {
  int N;
  string Out;
   cin >> N;
  
  Out = "Three";
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    
    if (str == "Y") {
      Out = "Four";
      break;
    }
  }    
   cout << Out <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using pchar = pair<char,char>;

int simulate(const string &s, const vector<pchar> &td, int pos) {
    for (auto c : td) {
        if (s[pos] != c.first) continue;
        if (c.second == 'L') --pos;
        else ++pos;
        if (pos < 0) return -1;
        if (pos >= (int)s.size()) return 1;
    }
    return 0;
}

int solve(const string &s, const vector<pchar> &td) {
    int N = (int)s.size();
    
    // 左側の境目
    int low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == -1) low = mid;
        else high = mid;
    }
    int left_fall = high;

    // 右側の境目
    low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == 1) high = mid;
        else low = mid;
    }
    int right_fall = N-1-low;

    //cout << left_fall << ", " << right_fall << endl;
    
    return N - (left_fall + right_fall);
}

int main() {
    int N, Q; string s; cin >> N >> Q >> s;
    vector<pchar> td(Q);
    for (int i = 0; i < Q; ++i) cin >> td[i].first >> td[i].second;
    cout << solve(s, td) << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int M, K;
    cin >> M >> K;

    if(M <= 1){
        if(K != 0){
            cout << -1 << endl;
            return 0;
        }
        if(M == 0) cout << "0 0" << endl;
        else cout << "0 0 1 1" << endl;
        return 0;
    }
    int N = 1<<M;
    if(K >= N){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    ans.push_back(K);
    for(int i=0; i<N; i++){
        if(i == K) continue;
        ans.push_back(i);
    }
    ans.push_back(K);
    for(int i=N-1; i>=0; i--){
        if(i == K) continue;
        ans.push_back(i);
    }
    for(auto x : ans)
        cout << x << " ";
    cout << endl;
    return 0;
}

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

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

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

const ll INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1, INF);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    chmin(dp[i], dp[i - 1] + 1);
    for (int j = 6; i - j >= 0; j *= 6) {
      chmin(dp[i], dp[i - j] + 1);
    }
    for (int j = 9; i - j >= 0; j *= 9) {
      chmin(dp[i], dp[i - j] + 1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 4044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  String ab;
			  String[] strAry;
			  int a;
			  int b;


			  while(true){
			      ab = input.readLine();
		          strAry = ab.split(" ");
		          a=Integer.parseInt(strAry[0]);
	              b=Integer.parseInt(strAry[1]);

	              if(a==0&&b==0){
	        	      break;
	               }
	                  for(int i=0; i<a; i++){

	        	          for(int j=0; j<b-1; j++){
	        		          System.out.print('#');
	        		     
	        	          }
	        	          System.out.println('#');
                          //println??§?????????????????????????????¨???????????????
	                  }

	                  System.out.println("");
	              }



		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }

	}
}

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

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

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

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

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n;
    cin >> n;
    int x = n * 800;
    int y = n / 15 * 200;
    P(x-y);
    return 0;
}



Measured memory_bytes: 764
import math

n=int(input())

cou=0

for i in range(n):
    a=int(input())
    jg=True
    z=int(math.sqrt(a))+1
    for k in range(2,z):
        if a%k==0:
            jg=False
            break
    if jg==True:
        cou+=1

print(cou)




Measured memory_bytes: 5672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1(b%a?b-a:a+b);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int inf = 1e9;
int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<string> str(n);
		for(int i=0; i<n; i++){
			cin >> str[i];
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(i!=j && str[j].find(str[i])!=string::npos){
					str.erase(str.begin()+i);
					i--;
					n--;
					break;
				}
			}
		}
		
		vector<vector<int> > reduce(n, vector<int>(n, 0));
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int d=1; d<(int)min(str[i].length(), str[j].length()); d++){
					if(str[i].substr(str[i].length()-d, d) == str[j].substr(0,d)){
						reduce[i][j] = d;
					}
				}
			}
		}
		
		vector<vector<vector<int> > > dp(1<<n, vector<vector<int> >(n, vector<int>(n, 0)));
		for(int i=1; i<(1<<n)-1; i++){
			for(int j=0; j<n; j++){
				if((1<<j & i)!=0) continue;
				for(int s=0; s<n; s++){
					if((1<<s & i) == 0) continue;
					for(int e=0; e<n; e++){
						if((1<<e & i) == 0) continue;
						dp[1<<j | i][j][e] = max(dp[1<<j | i][j][e], dp[i][s][e]+reduce[j][s]);
						dp[1<<j | i][s][j] = max(dp[1<<j | i][s][j], dp[i][s][e]+reduce[e][j]);
					}
				}
			}
		}
		
		int ans = 0;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				ans = min(ans, -dp[(1<<n)-1][i][j]);
			}
		}
		for(int i=0; i<n; i++) ans += str[i].length();
		cout << ans << endl;
	}
	return 0;
}


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

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

  vector<int> b;
  for (int i = 0; i < n; i++) {
    if (i % 2)
      b.insert(b.begin(), a[i]);
    else
      b.push_back(a[i]);
  }
  
  if (n % 2) {
    cout << b.back();
    for (int i = n-2; i >= 0; i--) cout << " " << b[i];
  }
  else {
    cout << b.front();
    for (int i = 1; i < n; i++) cout << " " << b[i];
  }
  cout << endl;
}

Measured memory_bytes: 3828
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

int t[1000000];
int n = 900000;
int sum(int r) {
	int result = 0;
	for (; r >= 0; r = (r & (r + 1)) - 1)
		result += t[r];
	return result;
}

void inc(int i, int delta) {
	for (; i < n; i = (i | (i + 1)))
		t[i] += delta;
}


int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> values;
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		v[i] -= i + 1;
		values.push_back(v[i]);
	}
	sort(values.begin(), values.end());
	int med = values[n / 2];
	long long ans = 0;
	for (int x : v)
	{
		ans += abs(x - med);
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 2168
import sys
N,K,Q = map(int,input().split())

Ai = [int(input()) for i in range(Q)]
points = [0 for i in range(N)]
for i in Ai:
  points[i-1] += 1

for i in range(N):
  if K - Q + points[i] > 0:
    print("Yes")
  else:
    print("No")


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N+1);
  L[0] = 2;
  L[1] = 1;
  for(int i=1; i < N; i++){
    L[i+1] = L[i] + L[i-1];
  }
  cout << L[N] << endl;
}


Measured memory_bytes: 256
class RMQ
  def initialize(size)
    @index = 1
    @index *= 2 while @index < size
    @array = Array.new(@index * 2 - 1, 0)
  end

  def sum(x, y, k = 0, l = 0, r = @index)
    if r <= x || y <= l
      0
    elsif x <= l && r <= y
      @array[k]
    else
      sl = sum(x, y, k * 2 + 1, l, (l + r) / 2)
      sr = sum(x, y, k * 2 + 2, (l + r) / 2, r)
      [sl, sr].inject(&:+)
    end
  end

  def update(x, y)
    x += @index - 1
    @array[x] += y
    while x > 0
      x = (x - 1) / 2
      @array[x] = @array[(x * 2) + 1, 2].inject(&:+)
    end
  end
end

n, q = gets.split.map(&:to_i)
rmq = RMQ.new(n)
q.times do
  com, x, y = gets.split.map(&:to_i)
  com == 0 ? rmq.update(x - 1, y) : puts(rmq.sum(x - 1, y))
end



Measured memory_bytes: 8936
def main():
    from collections import deque
    S = deque([s for s in input()])
    T = deque([s for s in input()])
    N = len(S)
    for _ in range(N):
        if S == T:
            return print("Yes")
        S.rotate()
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

print((m*1900+(n-m)*100)*(2**m))


Measured memory_bytes: 65516
#include<stdio.h>
#include<stdlib.h>

int main(){
  int r,D,i;
  int out;
  int x;
  while(1){
    scanf("%d %d %d",&r,&D,&i);
    if(r>=2 && r<=5) out++;
    if(D>=1 && D<=100) out++;
    if(i>=D && i<=200) out++;
    if(out == 3){
      break;
    }else{
      exit(-1);
    }
  }
  for(int n=0;n<10;n++){
    x = r * i - D;
    printf("%d\n",x);
    i = x;
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1000000007;
ll f[201010], rf[201010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 201010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 201010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
//---------------------------------------------------------------------------------------------------
ll add(ll &a, ll b)
{
    a = (a+b)%MOD;
}
ll mul(ll &a, ll b)
{
    a = a * b % MOD;
}

int main()
{
    init();
    int n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int d = 1; d <= m-1; d++)
    {
        ll tmp = 1;
        mul(tmp, m-d);
        mul(tmp, n);
        mul(tmp, n);
        mul(tmp, d);
        mul(tmp, C(n*m-2, k-2));
        add(ans, tmp);
    }
    for(int d = 1; d <= n-1; d++)
    {
        ll tmp = 1;
        mul(tmp, n-d);
        mul(tmp, m);
        mul(tmp, m);
        mul(tmp, d);
        mul(tmp, C(n*m-2, k-2));
        add(ans, tmp);
    }
    cout << (ans+MOD)%MOD << endl;
}


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

int main() {
	int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  	int cost=a*x+b*y,maxmai=max(x,y);
  	
  	for(int i=0;i<=maxmai;i++){
    	cost=min(cost,max(0,(x-i)*a)+max(0,(y-i)*b)+2*i*c);
    }
  	cout<<cost<<endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long long res = 0;
	long long N, A[10]; cin >> N; for (int i = 1; i <= 5; i++) cin >> A[i];
	long long mymin = min(A[1], min(A[2], min(A[3], min(A[4], A[5]))));

	res = (N % mymin == 0) ? N / mymin + 4 :  N / mymin + 5;

	cout << res << endl;
}

Measured memory_bytes: 256
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
const int inf = 1<<30; // const ll inf = 1LL<<62;
const int mod = 1e9+7; // 998244353
const int N  = 2e5+5;

ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a,ll m){return binpow(a, m-2, m);}

ll factorial[1000005];
void init_factorial(){
    factorial[0] = 1;
    forr(i,1,1000003) //Usually 10**6+5 is a good choice
        factorial[i] = factorial[i-1] * i % mod;
}
ll nck(ll n, ll k){
    return factorial[n] * modinv(factorial[k], mod) % mod * modinv(factorial[n - k], mod) % mod;
}


bool cmp(ii a, ii b){
    ll xa=a.first,ya=a.second,xb=b.first,yb=b.second;
    if(ya<=yb&&xa<=xb) return true;
    if (ya>=yb&&xa>=xb) return false;
    return ya<=yb;
}
 
int main()
{
    FIN;
    init_factorial();

    ll h,w,n, x, y;
    cin >> h >> w >> n;
    ii z[n]; ll c[n];
    forn(i,n){
        cin >> y >> x;
        z[i] = {y, x};
    }
    sort(z,z+n,cmp); //Los anteriores molestan al actual
    ll ans = nck(h+w-2, h-1);

    forn(i,n){
        y=z[i].first,x=z[i].second;
        c[i] = nck(x+y-2,x-1);
        forn(j,i){
            ll a=z[j].first,b=z[j].second;
            if(a>y || b>x) continue;
            c[i] = (c[i] - c[j]*nck(y-a+x-b,x-b)%mod)%mod;
        }
        ans = (ans-c[i]*nck(h+w-x-y,w-x)%mod)%mod;
        ans = (ans+mod)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8320
#include <stdio.h>

int main(void){
    int k,a,b,i,x=1;

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

    for(i=0;i<10000;i++){
        x=k*i;
        if(x>=a){
            break;
        }
    }

    if(x>=a && x<=b){
        printf("OK\n");
    }else{
        printf("NG\n");
    }

    return 0;
}

Measured memory_bytes: 3164
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cA = Counter(A)

binomials = [0, 0, 1]
for i in range(3, max(cA.values()) + 1):
    binomials.append(binomials[-1] * i // (i - 2))

ans0 = sum(binomials[v] for v in cA.values())

for a in A:
    print(ans0 - binomials[cA[a]] + binomials[cA[a] - 1])


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

#define rep(i,n) for(long long int (i) = 0;(i) < (int)(n);(i)++)
#define rrep(i,a,b) for(long long int i = (a);i < (b);i++)

typedef long long ll;

using namespace std;

const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;

//-------------------------↓↓↓↓↓↓------------------------

ll par[ohara], ran[ohara], mi[ohara];

void init(int nn) {
	rep(i,nn){
		par[i] = i;
		ran[i] = 0;
        mi[i] = INF;
	}
}

ll root(ll xx){
    if(par[xx] == xx){
        return xx;
    }
    else{
        return par[xx] = root(par[xx]);
    }
}
 
void unite(ll xx,ll yy){
    xx = root(xx);
    yy = root(yy);
    if(xx == yy)return;
    
    if(ran[xx] < ran[yy]){
        par[xx] = yy;
    }
    else{
        par[yy] = xx;
        if(ran[xx] == ran[yy])ran[xx]++;
    }
}

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

   ll n, m, a[ohara], b, c, other[ohara], cnt = 0, group = 0, ans = 0;
   map<ll,ll> mp;
   map<ll,ll> mpp;
   map<ll,ll> help;

   cin >> n >> m;

   rep(i, n)cin >> a[i];

   init(n + 1);

   rep(i, m){
     cin >> b >> c;
     b++;c++;
     unite(b,c);
   }

   rrep(i, 1, n + 1){
     mi[root(i)] = min(a[i - 1], mi[root(i)]);
     help[root(i)]++;
   }

   rrep(i, 1, n + 1){
     if(help[root(i)] != 0){
       group++;
       help[root(i)] = 0;
     }
     if(mp[root(i)] == 0){
       ans += mi[root(i)];
       mp[root(i)]++;
     }
   }

   rrep(i, 1, n + 1){
     if(a[i - 1] == mi[root(i)]){
       if(mpp[root(i)] == 0)mpp[root(i)]++;
       else other[cnt++] = a[i - 1];
     }
     else{
       other[cnt++] = a[i - 1];
     }
   }

   if(cnt < group - 2)cout << "Impossible" << "\n";
   else{
     if(group == 1)cout << 0 << "\n";
     else{
       sort(other,other + cnt);
       rep(i,group - 2){
         ans += other[i];
       }
       cout << ans << "\n";
     }
   }

       
return 0;
}


Measured memory_bytes: 32640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define Rep(i,a) for(int i = 0; i < a; i++)
using namespace std;
#define pb(a) push_back(a)
const int N = 1e5 + 10;
int n, a[N];
vector<int> ch[N], s[N]; int f[N];
void dfs(int x) {
	int len = ch[x].size();
	Rep(i,len) dfs(ch[x][i]);
	sort(s[x].begin(), s[x].end());
	f[x] = len;
	Rep(i,len) f[x] = max(f[x], s[x][i] + len - i);
	if (x > 1) s[a[x]].pb(f[x]);
}

int main() {
	scanf("%d",&n); rep(i,2,n) scanf("%d",a + i);
	rep(i,2,n) ch[a[i]].pb(i);
	dfs(1);
	printf("%d\n",f[1]);
	return 0;
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

string r(int a, int b) {
  string s = "";

  for (ll i = 0; i < b; i++) {
    char bf[10];
    sprintf(bf, "%d", a);
    s += bf;
  }
  return s;
}

int main() {
  ll a, b;
  scanf("%lld %lld", &a, &b);

  if (a < b) {
    cout << r(a, b) << endl;
  } else {
    cout << r(b, a) << endl;
  }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int n;
vector<vector<int>> level;

void dfs(int start, int end, int depth) {
    if(start >= end) return;
    int mid = (start+end)/2;
    for(int i = start; i <= mid; ++i) {
        for(int j = mid+1; j <= end; ++j) {
            level[i][j] = depth;
        }
    }
    
    dfs(start, mid, depth+1);
    dfs(mid+1, end, depth+1);
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    level.resize(n+1, vector<int>(n+1));

    dfs(1, n, 1);

    for(int i = 1; i <= n; ++i) {
        for(int j = i+1; j <= n; ++j) {
            cout << level[i][j] << ' ';
        }
        cout << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 1536
#pragma GCC target("avx,avx2,fma")

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void print(T t, V... v) {_print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

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

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;


void solve(){
    int n;
    cin >> n;
    vi a(n),b(n);
    
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    
    sort(all(b),greater<int>());
    
    int back = n-1;
    int front = 0;
    
    for(int i=0;i<n;i++){
        int curr = a[i];
        back = n-1,front = 0;
        
        while(i<n && a[i]==curr){
            if(a[i]==b[i]){
                if(back>i && a[i]!=b[back] && b[i]!=a[back])
                 swap(b[i],b[back]), back--;
                
                else if(front<i && a[i]!=b[front] && b[i]!=a[front])
                 swap(b[i],b[front]), front++;
                
                else{
                  cout << "No"; 
                  return;
                }
            }
            i++;
        }
        i--;
    }
    
    cout << "Yes\n";
    for(auto x:b) cout << x << " ";
}

int main(){
    IOS;
    solve();
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
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();}

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd


int main(){
  ll n,k;
  cin >> n >> k;
  ll maxNum = 0;
  VLL a(n);
  rep(i,n){
    cin >> a[i];
    maxNum = max(a[i],maxNum);
    if(a[i] == k){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  if(maxNum < k){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  ll gcdNum = a[0];
  rep(i,n){
    gcdNum = gcd(a[i],gcdNum);
  }
  if(gcdNum == 1){
    cout << "POSSIBLE" << endl;
    return 0;
  }else if(k % gcdNum == 0){
    cout << "POSSIBLE" << endl;
    return 0;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

#define int ll

void read() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	int add = min(a, k);
	ans += 1 * add;
	a -= add;
	k -= add;
	add = min(b, k);
	b -= add;
	k -= add;
	add = min(c, k);
	ans -= 1 * add;
	cout << ans << endl;
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m, res;
int h[N], e[M], ne[M], idx;
bool st[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int cnt)
{
	if (cnt >= n)
	{
		res ++ ;
		return;
	}

	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (st[j]) continue;

		st[j] = true;
		dfs(j, cnt + 1);
		st[j] = false;
	}
}

int main()
{
	memset(h, -1, sizeof h);
	cin >> n >> m;
	
	while (m -- )
	{
		int a, b;
		cin >> a >> b;

		add(a, b), add(b, a);
	}
	
	st[1] = true;
	dfs(1, 1);
	
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3924
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<string>

using namespace std;

int main(){
    int i,j,k;
    int N,M,x,y,z;
    cin >> N >> M;
    vector<vector<int>> to(N);
    vector<bool> d(N,false);
    for(i=0;i<M;i++){
        cin >> x >> y >> z;
        x--;
        y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    int count=0;
    queue<int> que;
    for(i=0;i<N;i++){
        if(d[i]) continue;
        que.push(i);
        while(!que.empty()){
            int q = que.front();que.pop();
            for(j=0;j<to[q].size();j++){
                int v = to[q][j];
                if(d[v]) continue;
                que.push(v);
                d[v] = true;
            }

        }
        count++;
    }
    cout << count << endl;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(i,N)cin>>A[i];
    sort(A.rbegin(),A.rend());
    int res = 0;
    rep(i,N){
        if(i%2==0)res+=A[i];
        else res-=A[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

void solve(){
  char c; cin>>c;
  if(c>='A' && c<='Z') c='A';
  else c='a';
  cout<<c;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
  return 0;
}

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

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  char p,q,r;
  p = A[0] - 32;
  q = B[0] - 32;
  r = C[0] - 32;
  cout << p << q << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

vector<int> solve(lint x){
	if(x == 1) return vector<int>();
	if(x & 1){
		auto ret = solve(x-1);
		for(auto &i : ret) i++;
		ret.push_back(1);
		return ret;
	}
	auto ret = solve(x >> 1);
	ret.push_back(ret.size() + 1);
	return ret;
}

int main(){
	lint n;
	cin >> n;
	n++;
	vector<int> perm = solve(n);
	cout << 2 * perm.size() << endl;
	for(auto &i : perm) cout << i << " ";
	for(int i=1; i<=perm.size(); i++) cout << i << " ";
}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
ans = 0
temp = h[0]
count = 0
for i in range(1, n):
    if temp >= h[i]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
    temp = h[i]
ans = max(ans, count)
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end(),greater<int>());
  ll sum = 0;
  rep2(i,k,n){
    sum += a[i];
  }
  cout << sum << endl;
  
  
    
  
}


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

typedef pair<int, int> P;

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> v(m,vector<int>(n));
    rep(i,m){
        int tmp;
        cin >> tmp;
        rep(j,tmp){
            cin >> v[i][j];
        }
    }
    vector<int> p(m);
    rep(i,m)cin >> p[i];

    int ans = 0;
    rep(i, 1<< n){
        bool ok = true;
        rep(j,m){
            int num = 0;
            rep(k,v[j].size()){
                if(i >> v[j][k]&1){
                    num++;
                }
            }
            num += p[j];
            if(num%2!=0){
                ok = false;
                break;
            }
        }
        if(ok){
            ans++;
        }

    }

    cout << ans << endl;

    return 0;
}

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

const int INF = 1e8;
const int H = 1000, W = 1000;

int h, w;
char a[H][W];

int d[H][W];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) d[i][j] = INF;
  queue<P> que;
  rep(i, h) rep(j, w) if (a[i][j] == '#') {
    que.push(make_pair(i, j));
    d[i][j] = 0;
  }
  while (que.size()) {
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    rep(i, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if (d[nx][ny] > d[x][y] + 1) {
        que.push(make_pair(nx, ny));
        d[nx][ny] = d[x][y] + 1;
      }
    }
  }
  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, d[i][j]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15964
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back

const int N = 2e5;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
string s;
int n;
int ar[N + 5];
map<int, int> MAP;
int dp[N + 5];
int main(){
  cin >> s;
  n = (int) s.length();
  int xornow = 0;
  for(int i = 0;i < n; ++i){
    int idx = s[i] - 'a';
    xornow ^= (1 << idx);
    ar[i] = xornow;
  }
  MAP[0] = 0;
  for(int i = 0;i < n; ++i){
    int now = ar[i];
    dp[i] = -1;
    for(int j = 0;j < 26; ++j){
      int tmp = ar[i] ^ (1 << j);
      if(MAP.count(tmp)){
        int res = MAP[tmp] + 1;
        if(dp[i] == -1 || dp[i] > res){
          dp[i] = res;
        }
      }
    }
    if(MAP.count(ar[i])){
      int res = MAP[ar[i]] + 1;
      if(dp[i] == -1 || dp[i] > res){
        dp[i] = res;
      }
    }

    //printf("%d %d %d\n", i, ar[i], dp[i] );
    if(MAP.count(now)) MAP[now] = min(MAP[now], dp[i]);
    else MAP[now] = dp[i];
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 11396
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;

const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> p(n),p1,p2,p3;
    for(int i=0;i<n;i++){
        cin >> p[i];
        if(p[i]<=a){
            p1.push_back(p[i]);
        }else if(a<p[i]&&p[i]<=b){
            p2.push_back(p[i]);
        }else if(b<p[i]){
            p3.push_back(p[i]);
        }
    }
    cout << min(p1.size(),min(p2.size(),p3.size())) << endl;

    return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> Num(N, 0);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		Num[A-1]++;
	}
	sort(Num.begin(), Num.end(), greater<int>());
	int ans = 0;
	for (int i = K; i < N; i++) {
		ans += Num[i];
		if (Num[i] == 0) break;
	}
	cout << ans;


}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
	
		String S = keyboard.next();
		
		String[] ss = S.split("");
		Arrays.sort(ss);
		
		if(ss[0].equals(ss[3])) {
			System.out.println("No");
		}else if(ss[0].equals(ss[1]) && ss[2].equals(ss[3])) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		keyboard.close();	
	}
}

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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    int n,m;
    cin>>n>>m;
    if(m < n)
    {
        cout<<"No"<<endl;
    }
    else if(m==n)
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

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

using namespace std;

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


int main(void)
{
	int m, n;

	while(scanf("%d%d", &m, &n)==2)
	{
		int ans=0;
		if(m>1) ans+=m*(m-1)/2;
		if(n>1) ans+=n*(n-1)/2;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128