akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) if(s[i] == t[i]) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 256
// Example program
#include <iostream>
#include <string>

using namespace std;

int n, a1[110], a2[110];

int main()
{
  cin >> n;
  
  for (int i = 0; i < n; ++i) {
    cin >> a1[i];   
  }
   
  for (int i = 0; i < n; ++i) {
    cin >> a2[i];   
  }
  
  int max = -1;
  for (int i = 0; i < n; ++i) {
      int acc = 0;
      for (int j = 0; j <= i; ++j) {
        acc += a1[j];
      }
      for (int j = i; j < n; ++j) {
        acc += a2[j];
      }
      if (acc > max) max = acc;
  }
  
  cout << max << "\n";
  
  return 0;
}


Measured memory_bytes: 256
/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                                                                

const bool flag = 0;

const int N = 1e7+1;

int cnt[N];

void ma1n() {
    int n;
    cin >> n;
    fill(cnt, cnt+N, 1);
    ll ans = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = i; j <= n; j += i) {
            cnt[j]++;
        }
        ans += cnt[i] * 1ll * i;
    }
    cout << ans;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

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

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

int main(void) {
    string week[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    for (Int i = 0; i < 7; ++i) {
        if (week[i] == s) {
            cout << 7 - i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3488
#include <cstdio>
int main(){
	int N, K;
	scanf("%d %d", &N, &K)+1;
	double total = 0.0;

	for (int i = 1; i <= N; i++) {
		if (i >= K) {
			total += N - K + 1;
			break;
		}
		double tt = 1.0;
		int ii = i;
		while (ii < K) {
			tt /= 2;
			ii *= 2;
		}
		total += tt;
	}

	total /= N;
	printf("%.12f\n", total);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C[5];
    cin>>A>>B;
    C[0]=A+B;
    C[1]=A-B;
    C[2]=A*B;
    sort(C,C+3);
    cout<<C[2]<<endl;
    return 0;
}


Measured memory_bytes: 256
#c
x,n=map(int, input().split())
p = list(map(int, input().split()))
ans = x
count = 0
while True:
    ans =  x - count
    if ans not in p:
        print(ans)
        break
    ans = x + count
    if ans not in p:
        print(ans)
        break
    count += 1

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;
#define lli long long int

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	int ans = min(b,n*a);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    vector<ll> c(27,0);
    for(ll i=0;i<26;++i)cin>>c[i+1];
    vector<vector<ll>> S(D+1, vector<ll>(27, 0));
    for(ll i=0;i<D;++i)
        for(ll j=0;j<26;++j)cin>>S[i+1][j+1];
    vector<ll> last(27,0);
    for(ll i=1;i<=D;++i){
        set<P> hoge;
        for(ll j=1;j<=26;++j){
            hoge.insert(P(S[i][j]+c[j]*c[j],j));
        }
        prt((*--hoge.end()).second);
    }fl

    return 0;
}



Measured memory_bytes: 3756
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var D = sc.nextInt();
        var ans = "Christmas";
        for (int i = 25; i > D; i--) {
            ans = ans + " Eve";
        }
        WriteLine(ans);
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

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

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li n,k; cin >>n >>k;
  li l=(n-1)*(n-2)/2;
  if(k>l){
    print(-1);
    return 0;
  }
  print(n-1+l-k);
  rep(i,n-1){
    print(i+1,n);
  }
  int i=1,j=i+1;
  rep(_,l-k){
    print(i,j);
    j++;
    if(j>=n){
      i++;
      j=i+1;
    }
  }
}


Measured memory_bytes: 3604
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-22 22:15:45
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int l; cin >> l;

  double len = static_cast<double>(l) / 3.0;

  cout << setprecision(17) << len * len * len << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,x,y;
  cin >>n>>m>>x>>y;
  int a[n+1],b[m+1];
  for(int i=0;i<n;i++){
  cin >>a[i];}
  a[n]=x;
  for(int i=0;i<m;i++){
  cin>>b[i];}
  b[m]=y;
  sort(a,a+n+1);
  sort(b,b+m+1);
  if (a[n]>=b[0])cout<<"War"<<endl;
  else cout<<"No War"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    long long  Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    long long ans;
    long long min1 = min({4 * Q, 2 * H, S});
    long long min2 = min({8 * Q, 4 * H, 2 * S, D});

    ans = min2 * (N / 2) + min1 * (N % 2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
import java.util.*;
import static java.lang.System.*;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(in);
	int h, w, c;
	int[] order = new int[5];
	int max;
	int[][] p;
	int[][] q;
	
	Queue<Integer> qx = new LinkedList<Integer>();
	Queue<Integer> qy = new LinkedList<Integer>();
	
	
	int calc() {
		int ans = 0;
		int[] dx = {-1, 0, 1, 0};
		int[] dy = {0, -1, 0, 1};
		int x, y;
		boolean[][] check = new boolean[h][w]; 
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < h; j++)
				Arrays.fill(check[j], false);
			qx.add(0); qy.add(0);
			check[0][0] = true;
			int color = q[0][0];
			while(!qx.isEmpty()) {
				x = qx.poll();
				y = qy.poll();
				q[x][y] = order[i];
				for (int j = 0; j < 4; j++) {
					if (x+dx[j] >= 0 &&
						x+dx[j] < h &&
						y+dy[j] >= 0 &&
						y+dy[j] < w &&
						!check[x+dx[j]][y+dy[j]] &&
						q[x+dx[j]][y+dy[j]] == color) {
						check[x+dx[j]][y+dy[j]] = true;
						qx.add(x+dx[j]);
						qy.add(y+dy[j]);
					}
				}
			}
		}
		
		for (int j = 0; j < h; j++)
			Arrays.fill(check[j], false);
		qx.add(0); qy.add(0);
		check[0][0] = true;
		while(!qx.isEmpty()) {
			x = qx.poll();
			y = qy.poll();
			ans++;
			for (int j = 0; j < 4; j++) {
				if (x+dx[j] >= 0 &&
					x+dx[j] < h &&
					y+dy[j] >= 0 &&
					y+dy[j] < w &&
					!check[x+dx[j]][y+dy[j]] &&
					q[x+dx[j]][y+dy[j]] == order[4]) {
					check[x+dx[j]][y+dy[j]] = true;
					qx.add(x+dx[j]);
					qy.add(y+dy[j]);
				}
			}
		}
		return ans;
	}
	
	void copy() {
		for (int i = 0; i < h; i++)
			 for (int j = 0; j < w; j++)
				 q[i][j] = p[i][j];
			
	}
	
	void recursion(int d) {
		 if (d == 4) {
			 copy();
			 max = Math.max(calc(), max);
		 } else {
			 for (int i = 1; i <= 6; i++) {
				 order[d] = i;
				 recursion(d+1);
			 }
		 }
		
	}
	
	void run() {
		while(true) {
			h = sc.nextInt();
			w = sc.nextInt();
			c = sc.nextInt();
			if (h == 0 && w == 0 && c == 0)
				break;
			p = new int[h][w];
			q = new int[h][w];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					p[i][j] = sc.nextInt();
			
			max = 0;
			order[4] = c;
			recursion(0);
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}} End

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  priority_queue<i64, vector<i64>, greater<>> que;
  rep(i, N) {
    int a; cin >> a;
    que.emplace(a);
  }
  vector<pii> vec(M);
  rep(i, M) {
    int b, c; cin >> b >> c;
    vec[i] = pii(c, b);
  }
  sort(all(vec), greater<>());
  for (auto& e : vec) {
    i64 loop = e.second, norm = e.first;
    rep(i, loop) {
      if (norm <= que.top()) break;
      que.pop();
      que.emplace(norm);
    }
  }
  i64 res = 0;
  while (que.size()) {
    res += que.top();
    que.pop();
  }
  cout << res << "\n";
  return 0;
}


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

int main(void){
    vector<bool> c(3,false);
    int a,b;
    cin>>a;
    cin>>b;
    if(a==1||b==1){
       c[0]=true;
    }
    if(a==2||b==2){
       c[1]=true; 
    }
    if(a==3||b==3){
       c[2]=true; 
    }
    for(int j=0;j<3;j++){
        if(c[j]==false){
        cout<<j+1<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

using Graph = vector<vector<int>>;

vector<bool> visited;
vector<LL> cost;

vector<LL> ans;
int n, q;

void dfs(const Graph &G, int v,LL val) {
	visited[v] = true; // v を訪問済にする
	val += cost[v];

	ans[v] = val;

	// v から行ける各頂点 next_v について
	for (auto next_v : G[v]) {
		if (visited[next_v]) continue; // next_v が探索済だったらスルー
		dfs(G, next_v,val); // 再帰的に探索
	}
}

int main() {
	cin >> n >> q;

	Graph G(n);

	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;

		G[a].push_back(b);
		G[b].push_back(a);
	}

	cost.resize(n);

	for (int i = 0; i < q; i++) {
		int p; cin >> p;
		p--;
		LL x; cin >> x;

		cost[p] += x;

	}

	visited.resize(n);
	ans.resize(n);
	
	dfs(G, 0, 0);

	for (int i = 0; i < n; i++) {
		cout << ans[i];

		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> Qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> Qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int s,w;
  cin >> s >> w;
  if(s<=w) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n;cin>>n;
  string S;cin>>S;
  int curr=0,pr=0,res=0;
  for(int i=0;i<n;i++){
    curr = S[i]-'a' + 1;
    if(curr!=pr){res++;}
    pr=curr;
  }
  cout<<res;
  return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

#define N_MAX 12
#define M_MAX 1000

int n, m;
int a[M_MAX], b[M_MAX], c, c_bit[M_MAX] = {};

void print_c(){
	REP(i, m){
		cout << c_bit[i] << ' ';
	}
	cout << endl << endl;
}

void input(){
	cin >> n >> m;
	REP(i, m){
		cin >> a[i] >> b[i];
		REP(j, b[i]){
			cin >> c;
			c_bit[i] += 1 << c-1;
		}
	}

	//print_c();
}

int dp[M_MAX][1 << N_MAX];

void init(){
	REP(i, M_MAX){
		REP(j, 1 << N_MAX){
			dp[i][j] = INT_MAX;
		}
	}
}

void print_dp(){
	REP(i, m){
		REP(j, 1 << n){
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}
	cout << endl;
}

int solve(){
	init();

	REP(i, m){
		dp[i][c_bit[i]] = a[i];
		if(!i) continue;
		REP(j, 1 << n){
			dp[i][j] = MIN(dp[i-1][j], dp[i][j]);
			if(dp[i][j] != INT_MAX) dp[i][j|c_bit[i]] = MIN(dp[i][j|c_bit[i]], dp[i][j]+a[i]);
		}
	}

	//print_dp();

	int ans = dp[m-1][(1 << n)-1];
	if(ans != INT_MAX) cout << ans << endl;
	else cout << -1 << endl;
}

int main(void){
	input();

	solve();

	return 0;
}


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

const ll MOD = 1e9 + 7;

ll mod(ll a) {
	return (a % MOD + MOD) % MOD;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	vector<ll> r(n, 0);
	r[0] = a[0];
	for (ll i = 1; i < n; ++i)r[i] = mod(r[i - 1] + a[i]);
	ll ans = 0;
	for (ll i = 0; i < n; ++i) {
		ll sum = mod(a[i] * mod(r.back() - r[i]));
		ans += sum;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,r;
    cin >> n >> r;
    if (n>=10) cout << r << endl;
    else cout << r+(10-n)*100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1000+6,mod=1e9+7;
typedef long long ll;
int r,c,dp[N][N];
string s[N];
bool valid(int i,int j){
    return i>=0 && i<r && j>=0 &&j<c && s[i][j]=='.';
}
int solve(int i,int j){
    if(i==r-1 && j==c-1)return 1;
    int &ret=dp[i][j];
    if(~ret)return ret;
    ret=0;
    if(valid(i,j+1))ret+=solve(i,j+1);
    ret%=mod;
    if(valid(i+1,j))ret+=solve(i+1,j);
    ret%=mod;
    return ret;
}
int main()
{
    input();
    cin>>r>>c;
    for(int i=0;i<r;i++)cin>>s[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0)<<endl;

}



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

const double PI = 3.14159265358979323846;

int main() {
  int r;
  cin >> r;
  double ans = (double)2.0 * (double)r * PI;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int k = scan.nextInt();
		int c = scan.nextInt();
		String s = scan.next();
		
		int[] left = new int[n];
		int count = 0;
		for(int i = 0; i < n; i++){
			if(s.charAt(i) != 'x') {
				left[i] = count+1;
				i += c;
				count++;
				if(count == k) break;
			}
		}
		
		int[] right = new int[n];
		count = 0;
		for(int i = n-1; i >= 0; i--) {
			if(s.charAt(i) != 'x') {
				right[i] = k-count;
				i -= c;
				count++;
				if(count == k) break;
			}
		}
		
		for(int i = 0; i < n; i++) 
			if(left[i] == right[i] && left[i] != 0)
				System.out.println(i+1);
	}
}

Measured memory_bytes: 53264
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int res = 0;
    for(int i = 1; i <= N; i++) {
        if(i >= 1 && i <= 9)
            res++;
        else if(i >= 100 && i <= 999)
            res++;
        else if(i >= 10000 && i <= 99999)
            res++;
    }
    cout << res << endl;
    return 0;
}

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

const int N = 2e5;

int cnt[N];
int main(){
    int n;
    cin >> n;
    int mx = 0;
    for (int i = 1; i <= n; ++i){
        int l;
        cin >> l;
        cnt[l]++;
        cnt[l-1]++;
        cnt[l+1]++;
        mx = max(mx, max(cnt[l], max(cnt[l-1], cnt[l+1])));
    }
    cout << mx << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a < b)
  cout << "a < b" << endl;
else if(a > b)
  cout << "a > b" << endl;
  else
  cout << "a == b" << endl;
  return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;

int main(){
	string a,b;
	cin >> a >> b;
	
	if(a.size()>b.size())
	{
		cout << "GREATER" << endl;
	}
	else if(a.size()<b.size())
	{
		cout << "LESS" << endl;
	}
	else if(a.size()==b.size())
	{
		if(a>b)
		{
			cout << "GREATER" << endl;
		}
		else if(a<b)
		{
			cout << "LESS" << endl;
		}
		else
		{
			cout << "EQUAL" << endl;
		}
	}
		
	return 0;
}


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

const int MOD = 1000000007;
int n, k;

int a[100000];
int b[100000];
int c[100000];
int len;
void pre() {
  int p = 1;
  int i = 0;
  while (p * p <= n) {
    a[i] = p;
    b[i] = n / p;
    ++p;
    ++i;
  }
  --p;
  if (p * p == n) --i;
  while (p > 0) {
    a[i] = n / p;
    b[i] = p;
    --p;
    ++i;
  }
  len = i;
}

int DP[101][100000];
int DQ[101][100000];
int main() {
  cin >> n >> k;
  pre();
  
  c[0] = 1;
  for (int i = 0; i < len; ++i) {
    c[i] = a[i] - a[i - 1];
  }
  
  DP[0][0] = 1;
  DQ[0][0] = DP[0][0];
  for (int i = 1; i < len; ++i) {
    DP[0][i] = c[i];
    DQ[0][i] = DQ[0][i - 1] + DP[0][i];
  }
  
  for (int j = 1; j < k; ++j) {
    for (int i = 0; i < len; ++i) {
      int v = len - i - 1;
      DP[j][i] = (long)DQ[j - 1][v] * c[i] % MOD;
    }
    
    DQ[j][0] = DP[j][0];
    for (int i = 1; i < len; ++i) {
      DQ[j][i] = (DQ[j][i - 1] + DP[j][i]) % MOD;
    }
  }
  
  cout << DQ[k - 1][len - 1] << endl;  
}

Measured memory_bytes: 79488
mod = int(1e9) + 7
n = int(input())
a = list(map(int, input().split()))
lis = [0] * n
for i in a:
    lis[i] += 1
for i in range(1,n):
    if lis[i] % 2 == 1:
        print(0)
        exit()

print(pow(2, n//2, mod)) 


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

using namespace std;

using int64 = long long;

int main()
{
  int N;
  scanf("%d", &N);
  vector< pair< int, int > > D(N);
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &D[i].first, &D[i].second);
  }
  sort(D.begin(), D.end());

  int ret = 0;
  priority_queue< pair< int, int >, vector< pair< int, int > >, greater< pair< int, int > > > que;
  priority_queue< int, vector< int >, greater< int > > que2;
  int64 A = 0;
  int in[100001] = {};
  for(auto &p : D) {
    que.emplace(p.second, p.first);
    A += p.first;
    que2.emplace(p.second);
    while(A > 1LL * que2.top() * que.size()) {
      A -= que.top().second;
      ++in[que.top().first];
      while(in[que2.top()] > 0) {
        --in[que2.top()];
        que2.pop();
      }
      que.pop();
    }
    ret = max(ret, (int) que.size());
  }

  cout << ret << endl;
}


Measured memory_bytes: 11744
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll n, k, ans1, ans2;

    cin >> n >> k;

    ans1 = n/k;
    ans2 = n/k + 1;

    if (abs(n - ans1 * k) < abs(n - ans2 * k)) {
        COUT(abs(n - ans1 * k));
    }
    else{
        COUT(abs(n - ans2 * k));
    }
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 2010
#define MOD 998244353
using namespace std;
typedef long long ll;
ll C[2*MAXN][2*MAXN],bits[2*MAXN];
int n,k;
ll count(int s,int tot){
    return C[s+tot-1][s-1]; 
}
ll solve(int i,int tot){
    int k2=min(k-i/2,(i-1)/2);
    int k1=k-k2*2-((i%2)==0);
    ll flag=1;
    ll res=0;
    for(int l=k2;l+k1>0&&l>=0;l--,flag=-flag){
        res+=flag*count(l+k1,tot)*bits[l]%MOD*C[k2][l]%MOD;
        res%=MOD;
    }
    return (res+MOD)%MOD;
}
int main(){
    SF("%d%d",&k,&n);
    int sum=0;
    bits[0]=1;
    for(int i=1;i<=4000;i++)
        bits[i]=bits[i-1]*2ll%MOD;
    C[0][0]=1;
    for(int i=1;i<=4000;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
    }
    ll ans=0;
    for(int i=2;i<=2*k;i++){
        if(i%2==0){
            ans=(solve(i,n)+solve(i,n-1))%MOD;
        }
        else{
            ans=solve(i,n);
        }
        PF("%lld\n",ans);
    }
}

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

double get_dp_value(vector<vector<vector<double>>> &dp, vector<int> &count)
{
    return dp[count[0]][count[1]][count[2]];
}

void set_dp_value(vector<vector<vector<double>>> &dp, vector<int> &count, double x)
{
    dp[count[0]][count[1]][count[2]] = x;
}

double dfs(vector<int> &count, vector<vector<vector<double>>> &dp)
{
    if (get_dp_value(dp, count) < 0)
    {
        int n = dp.size() - 1;
        double ret = 0.0;
        int non_zero = 0;
        for (int c : count)
        {
            non_zero += c;
        }
        int zero = n - non_zero;

        double p_zero = (double)zero / n;
        double p_non_zero = (double)non_zero / n;
        double p;
        vector<int> next_count;
        for (int i = 0; i < count.size(); i++)
        {
            if (count[i] == 0)
            {
                continue;
            }
            next_count = count;
            next_count[i]--;
            if (i > 0)
            {
                next_count[i - 1]++;
            }
            p = (double)count[i] / n;
            ret += p / ((1 - p_zero) * (1 - p_zero));
            ret += (double)count[i] / non_zero * dfs(next_count, dp);
        }
        set_dp_value(dp, count, ret);
    }
    return get_dp_value(dp, count);
}

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

    int a;
    vector<int> count(3, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        a--;
        count[a]++;
    }

    vector<vector<vector<double>>> dp(
        N + 1,
        vector<vector<double>>(
            N + 1,
            vector<double>(N + 1, -1.0)));

    cout << fixed << setprecision(10) << dfs(count, dp) << endl;
}


Measured memory_bytes: 216960
n = int(input())
alist = [int(i) for i in input().split()]

count = 0
for a in alist:
    if a < 0:
        count += 1

ans = 0
if count & 1 == 0:
    for a in alist:
        ans += abs(a)
else:
    mina = abs(alist[0])
    for a in alist:
        mina = min(mina, abs(a))
    for a in alist:
        ans += abs(a)
    ans -= mina * 2


print(ans)


Measured memory_bytes: 64880
#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>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {
    int N,R;
    cin >> N >> R;

    if(N >= 10){
        cout << R << endl;
    }
    else{
        cout << R + 100*(10-N) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;
#define MAX_V 100
#define INF (1<<24)
int V,E,a;
vector<int> G[MAX_V];
vector<int> g[MAX_V];
map<string,int> change;
string str;
int t[MAX_V];

void dijkstra(){
  priority_queue< P , vector<P> , greater<P> > Q;
  for(int i=0;i<V;i++)Q.push(P(t[i],i));
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second,cost=p.first;
    if(cost>t[pos])continue;
    for(int i=0;i<(int)g[pos].size();i++){
      int w=g[pos][i];
      int sum=0;
      for(int j=0;j<(int)G[w].size();j++)sum+=t[G[w][j]];
      if(sum<t[w]){
	t[w]=sum;
	Q.push(P(t[w],w));
      }
    }
  }
}

int main(){
  while(cin>>V&&V){
    for(int i=0;i<V;i++){
      cin>>str>>t[i];
      G[i].clear();
      g[i].clear();
      change[str]=i;
    }
    cin>>E;
    for(int i=0;i<E;i++){
      cin>>str;
      int v=change[str];
      cin>>a;
      for(int j=0;j<a;j++){
	cin>>str;
	G[v].push_back(change[str]);
	g[change[str]].push_back(v);
      }
    }
    dijkstra();
    cin>>str;
    cout<<t[change[str]]<<endl;
  }
  return 0;
}

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

int main() {
 int N,n;
 int s = 0;
 cin >> n;
 N = n;
 while(n){
   s += n%10;
   n /= 10;
 }
 cout << (N%s? "No" : "Yes") << endl;
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a( H, vector<char>( W ) );
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			cin >> a[i][j];
		}
	}

	map<char, int> m;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			m[ a[i][j] ]++;
		}
	}
	vector<int> b( m.size() );
	int k = 0;
	for( auto it = m.begin(); it != m.end(); it++ ) {
		b[k] = it->second;
		k++;
	}
	int r[8] = { 0 };
	for( int i = 0; i < k; i++ ) {
		r[ b[i] % 4 ]++;
	}
	string ans = "Yes";
	if( H % 2 && W % 2 ) {
		if( r[1] ) r[1]--;
		else {
			r[3]--;
			r[2]++;
		}
		if( r[1] || r[3] ) ans = "No";
		else {
			if( r[2] > H / 2 + W / 2 ) ans = "No";
		}
	}
	else if( H % 2 || W % 2 ) {
		if( r[1] || r[3] ) ans = "No";
		int l = H;
		if( H % 2 ) l = W;
		if( r[2] > l / 2 ) ans = "No";
	}
	else {
		if( r[1] || r[2] || r[3] ) ans = "No";
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
struct edge { int a, b, c; };
bool operator<(const edge& e1, const edge& e2) { return e1.c > e2.c; }
int n, m, ia, ib, ic, par[200009];
int root(int x) { return x == par[x] ? x : par[x] = root(par[x]); }
int main() {
	scanf("%d%d", &n, &m);
	std::priority_queue<edge> que;
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &ia, &ib, &ic);
		que.push(edge{ ia, ib, ic });
		que.push(edge{ (ia + 1) % n, ib, ic + 1 });
	}
	for (int i = 0; i < n; i++) par[i] = i;
	long long ret = 0;
	while (!que.empty()) {
		edge e = que.top(); que.pop();
		if (root(e.a) != root(e.b)) {
			par[root(e.a)] = root(e.b);
			ret += e.c;
			que.push(edge{ (e.a + 1) % n, (e.b + 1) % n, e.c + 2 });
		}
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 8560
def L(N, X):
    if N == 0:
        return 1

    a = 2 ** (N + 1) - 3
    b = 2 ** N - 1
    if X == 1:
        return 0
    elif X <= a + 1:
        return L(N-1, X-1)
    elif X == a + 2:
        return b + 1
    elif X <= 2 * a + 2:
        return b + 1 + L(N-1, X-a-2)
    else:
        return b * 2 + 1

def main():
    N, X = map(int, input().split())
    print(L(N,X))


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<iostream>

using namespace std;

int main(){
 int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a+b>c+d) cout << "Left" << endl;
  else if(a+b<c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;

}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N,x;
  cin>>N>>x;
  if(x==1||x==2*N-1) cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    queue<int> q,r;
    for(int i = 0; i < 2*N-1; i++){
      int t = i+1;
      if(t!=x-1&&t!=x&&t!=x+1) q.push(t);
      else r.push(t);
    }
    for(int i = 0; i < 2*N-1;i++){
      if(i!=N-2&&i!=N-1&&i!=N){
        cout<<q.front()<<endl;
        q.pop();
      }
      else{
        cout<<r.front()<<endl;
        r.pop();
      }
    }
  }
}
      

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

int main() {
    int n; cin >> n;
    int x = 0, y = 0;
    vector<int> V(n);
    vector<int> C(n);
    for(int i = 0; i < n; i++){
        cin >> V[i];
    }
    for(int i = 0; i < n; i++){
        cin >> C[i];
    }
    for(int i = 0; i < n; i++){
        if(V[i] > C[i]){
            x += V[i];
            y += C[i];
        }
    }
    cout << x - y;
}

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

using namespace std;
typedef long long ll;

struct BIT {
  int N;
  vector<int> data;
  explicit BIT(int n) : N(n + 1), data(n + 1) {}
  void add(int i, int v) {
    for(int x = i; x < N; x += x & -x) {
    	data[x] += v;
    }
  }
  int get(int i) {
    int ret = 0;
    for(int x = i; x > 0; x -= x & -x) {
    	ret += data[x];
    }
    return ret;
  }
};

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] -= K;
  }
  vector<ll> acc(N + 1);
  for(int i = 0; i < N; i++) {
    acc[i + 1] = acc[i] + A[i];
  }
  vector<ll> acc_ = acc;
  sort(acc_.begin(), acc_.end());
  
  BIT bit(N + 1);
  ll ans = 0;
  for(int i = 0; i < N + 1; i++) {
    int k = lower_bound(acc_.begin(), acc_.end(), acc[i]) - acc_.begin() + 1;
  	ans += bit.get(k);
    bit.add(k, 1);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


lln arr[maxii];
lln arr2[maxii];
//bool check[maxii];
bool check2[1000][1000];
//lln n,m;

int main()
{
 int a,b,c,d;
 cin>>a>>b>>c>>d;
 int p=max(a,c);
 int q=min(b,d);
 int res=q-p;
 if(res<0)res=0;
 cout<<res;

}






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

int main()
{
  int k,n;
  cin>>k>>n;
  std::vector<int> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  a.push_back(k+a[0]);
  ll diff=0;
  for (int i = 0; i < n; ++i)
  {
    ll tmp=abs(a[i]-a[i+1]);
    diff=max(tmp,diff);
  }
  cout<<k-diff;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 11
using namespace std;
int h,w;
string mp[N];
int dx[4]={0,1,0,-1};//^>V<
int dy[4]={-1,0,1,0};//^>V<
char ch[]={'U','R','D','L'};

bool check(int &y,int &x,int i){
  while(1){
    x+=dx[i],y+=dy[i];
    if(x<0||y<0||x>=w||y>=h) return 0;
    if(mp[y][x]=='o') return 1;
  }
}

string ans;
bool dfs(int y,int x,int dir,int cnt){
  if(cnt==0)return 1;
  
  for(int i=0;i<4;i++){
    int nx=x,ny=y;
    if((dir+2)%4==i||!check(ny,nx,i)) continue;
    mp[ny][nx]='.';
    if(dfs(ny,nx,i,cnt-1)){ans+=ch[i];return 1;}
    mp[ny][nx]='o';
  }
  return 0;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  
  int cnt=0,sx,sy,dir;  
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      char t=mp[i][j];
      if(t=='o')cnt++;
      if(t=='o'||t=='.')continue;
      sx=j,sy=i;
      if(t=='U')dir=0;
      if(t=='R')dir=1;
      if(t=='D')dir=2;
      if(t=='L')dir=3;
    }
  dfs(sy,sx,dir,cnt);
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3240
#include<stdio.h>
main(){
  int n,i=0,sya=100000;
  scanf("%d",&n);
  while(i<n){
    sya*=1.05;
    if(sya%1000!=0){
      sya=sya-(sya%1000)+1000;
    }
    i++;
  }
  printf("%d\n",sya);
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll N, M, L;
using Graph = vector<vector<Pll>>;
Graph g;

void dij(Vl& res, int start) {
    vector<Pll> cost(N, {L_INF, L_INF});
    using Tup = tuple<ll, ll, ll>;  // cost, -oil, idx
    priority_queue<Tup, vector<Tup>, greater<Tup>> q;
    q.emplace(0, -L, start);
    cost[start] = {0, -L};
    while (!q.empty()) {
        ll idx, co, oi;
        tie(co, oi, idx) = q.top();
        q.pop();
        oi = -oi;
        if (make_pair(co, -oi) > cost[idx]) continue;
        for (const auto& edge : g[idx]) {
            ll to, d;
            tie(to, d) = edge;
            ll nco, noi;
            if (oi - d >= 0) {
                nco = co;
                noi = oi - d;
            }
            else {
                nco = co + 1;
                noi = L - d;
            }
            Pll p = {nco, -noi};
            if (p >= cost[to]) continue;
            cost[to] = p;
            q.emplace(nco, -noi, to);
        }
    }

    res.resize(N);
    for (ll i = 0; i < N; i++) {
        res[i] = cost[i].first;
    }
}

void solve() {
    cin >> N >> M >> L;
    g.resize(N);
    for (ll i = 0; i < M; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        if (c > L) continue;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }

    vector<Vl> cost(N);
    for (ll i = 0; i < N; i++) {
        dij(cost[i], i);
    }

    ll Q;
    cin >> Q;
    for (ll i = 0; i < Q; i++) {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        ll ans = cost[a][b];
        if (ans == L_INF) {
            cout << -1 << "\n";
        }
        else {
            cout << cost[a][b] << "\n";
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main() {
    while(1){
        int a,l;
        cin >> a >> l;
        if(l==0)break;
        map<int,int> mp;
        int c = 0;
        while(mp.count(a)==0){
            mp[a] = c;
            c++;
            string s="";
            for(int i=0;i<l;i++){
                s += '0'+a%10;
                a/=10;
            }
            int amin,amax;
            sort(s.begin(),s.end());
            amin = stoi(s);
            sort(s.rbegin(),s.rend());
            amax = stoi(s);
            a = amax - amin;
        }
        cout << mp[a] << " " << a << " " << c-mp[a] << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  int i;
  for(i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  long ans = 0;
  int cnt = 0;
  for(i=1;i<n;i++){
    if(s[i] == s[i-1]) {
      cnt ++;
      ans += cnt;
    }else{
      cnt = 0;
    }
  }
  cout << ans;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

#define int long long

/*************** using variables ***************/
int n, c, k;
vector<int> t;
int ans = 1;
/**********************************************/

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

    cin >> n >> c >> k;
    t.resize(n);
    REP(i,n) cin >> t[i];
    
    sort(all(t));
    int cur = t[0];
    int cap = 1;
    FOR(i, 1, n){
        if(cur + k < t[i] || cap+1 > c){
            cur = t[i];
            cap = 1;
            ans++;
        }else{
            cap++;
        }
        //cout << cur << endl;
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
       try(Scanner sc = new Scanner(System.in)){
           while(true){
               int n = sc.nextInt();
               if(n==0)break;
               int[] scores = new int[n];
               for(int i=0;i<scores.length;i++){
                   scores[i] = sc.nextInt();
               }
               double average=0,variance=0;
               for(int i=0;i<scores.length;i++){
                   average += scores[i];
               }
               average /= (double)n;

               for(int i=0;i<scores.length;i++){
                   variance += (scores[i]-average)*(scores[i]-average);
               }
               variance /= (double)n;
               System.out.println(Math.sqrt(variance));
           }
       }    
    }

}


Measured memory_bytes: 31284
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>
#include<set>
#include<deque>

using namespace std;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	reverse(s2.begin(), s2.end());
	if (s1 == s2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

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

    for(int i = 0; i < s.size(); i++)
    {
        cout << 'x';
    }

    cout << '\n';

    return 0;
}


Measured memory_bytes: 256