akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e6;
int n;
inline void merge(vector<pair<char, int>> &a, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<pair<char, int>> L(n1), R(n2);
	copy(a.begin() + left, a.begin() + mid, L.begin());
	copy(a.begin() + mid, a.begin() + right, R.begin());
	L.eb(mp('Z', 1e9 + 5));
	R.eb(mp('Z', 1e9 + 5));
	int i = 0, j = 0;
	rep(k, left, right) {
		if(L[i].second <= R[j].second) {
			a[k] = L[i];
			++i;
		} else {
			a[k] = R[j];
			++j;
		}
	}
}
inline void mergeSort(vector<pair<char, int>> &a, int left, int right) {
	if(left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}
inline int partition(vector<pair<char, int>> &a, int p, int r) {
	int x = a[r].second;
	int i = p - 1;
	rep(j, p, r) {
		if(a[j].second <= x) {
			swap(a[++i], a[j]);
		}
	}
	swap(a[++i], a[r]);
	return i;
}
inline void quickSort(vector<pair<char, int>> &a, int p, int r) {
	if(p < r) {
		int q = partition(a, p, r);
		quickSort(a, p, q - 1);
		quickSort(a, q + 1, r);
	}
}
int main() {
	cin >> n;
	vector<pair<char, int>> v, mv; v.reserve(100001);
	char s;
	int x;
	rep(i, 0, n) {
		cin >> s >> x;
		v.eb(mp(s, x));
	}
	mv.assign(all(v));
	quickSort(v, 0, n - 1);
	mergeSort(mv, 0, n);
	P(v == mv ? "Stable" : "Not stable");
	rep(i, 0, n) {
		cout << v[i].first << ' ' << v[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 5876
n=int(input())
ans=0
arr=list(map(int,input().split()))
for i in range(1,n-1):
  nMax=max(arr[i-1],arr[i],arr[i+1])
  nMin=min(arr[i-1],arr[i],arr[i+1])
  if arr[i]!=nMax and arr[i]!=nMin:
    ans+=1
print(ans)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> m;
    rep(i, n) cin >> a[i];
    rep(i, n) m[a[i]] = i+1;
    rep(i, n) cout << m[i+1] << (i==n-1 ? "\n":" ");
}

Measured memory_bytes: 5888
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
        A[i] = sc.nextInt();
    }

    insertionSort(A, N);    
  }

  public static void insertionSort(int[] a, int n) {
      for (int i = 1; i < n; i++) {
          println(a);
          int tmp = a[i];
          int j = i - 1;
          while (j >= 0 && a[j] > tmp) {
              a[j+1] = a[j];
              j--;
          }
          a[j+1] = tmp;
      }
      println(a);
    }

  public static void println(int[] a) {
    System.out.println(Arrays.stream(a).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
  }
}


Measured memory_bytes: 33976
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll A=nxt(),B=nxt(),C=nxt();
    ll k=nxt();
    while(B<=A)
    {
        B*=2;
        k--;
    }
    while(C<=B)
    {
        C*=2;
        k--;
    }
    if(k>=0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
	printclock;
	return 0;
}

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'e') {
    cout << "vowel" << endl;
  }

  else if (c == 'i' || c == 'o') {
    cout << "vowel" << endl;
  }

  else if (c == 'u' ) {
    cout << "vowel" << endl;
  }
  else {
  cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * (n-t+1) for t in range(1, n+1)]
dp[0] = a
for t in range(1, n):
    for i in range(n-t):
        dp[t][i] = max(-dp[t-1][i+1] + a[i], -dp[t-1][i] + a[i+t])
print(dp[n-1][0])

Measured memory_bytes: 98800
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int inputA = sc.nextInt();
		int inputB = sc.nextInt();
		sc.close();
		
		BigDecimal bd = new BigDecimal(inputB + inputA);
		BigDecimal tw = new BigDecimal(2);
		
		System.out.println(bd.divide(tw, 0, BigDecimal.ROUND_UP));
	}
}

Measured memory_bytes: 21200
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import random

n = int(input())
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
# n = 10
# a = []
# b = []
# for _ in range(10):
#     a.append(random.randrange(1, 4))
#     b.append(random.randrange(1, 4))
# a.sort()
# b.sort()
# print(*a)
# print(*b)

b.reverse()

same_val = None
same_id = []
for i, (ai, bi) in enumerate(zip(a, b)):
    if ai == bi:
        same_val = ai
        same_id.append(i)

changeable = []
for i, (ai, bi) in enumerate(zip(a, b)):
    if b[i] != same_val and a[i] != same_val:
        changeable.append(i)

if len(same_id) > len(changeable):
    print("No")
    exit()
for s, c in zip(same_id, changeable):
    b[s], b[c] = b[c], b[s]

print("Yes")
print(*b)

Measured memory_bytes: 128016
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
int a[200005];
int b[200005];
int c[200005];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)b[i] = __gcd(a[i],b[i-1]);
    for(int i=n;i>=1;i--)c[i] = __gcd(a[i],c[i+1]);
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans,__gcd(b[i-1],c[i+1]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

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

    string s[N];
    int t[N];

    for (int i = 0; i < N; i++) {
        cin >> s[i] >> t[i];
    }

    string X;
    cin >> X;
    int i;
    for (i = 0; i < N; i++) {
        if (X == s[i]) {
            i++;
            break;
        }

    } 
    
    int sum = 0;
    for (; i < N; i++) {
        sum += t[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main(){
        int a1,a2,a3;
        while(~scanf("%d %d %d",&a1,&a2,&a3)){
            if(a1+a2+a3 >= 22){
                printf("bust\n");
            }else{
                printf("win\n");
            }
        }
    }


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define fir first
#define sec second
#define PB push_back
#define MP make_pair
using namespace std;
int SIZE=100000;
vector<int>V;
int lower(int a){
    int lb=-1,ub=V.size();
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        if(V[mid]>a){
            ub=mid;
        }else{
            lb=mid;
        }
    }
    return ub-1;
}
int main(){
    bool prime[SIZE+1];
    memset(prime,true,sizeof(prime));
    for(int i=2;i<=SIZE;i++){
        if(prime[i])for(int j=i*2;j<=SIZE;j+=i)prime[j]=false;
    }
    int m,a,b;
    for(int i=2;i<=SIZE;i++)if(prime[i])V.push_back(i);
    while(1){
        pair<int,int> ans;
        ans=MP(-1,1);
        cin>>m>>a>>b;
        if(m+a+b==0)break;
        REP(i,V.size()){
            int p=V[i];
            if(m/p<=1)break;
            int qq=lower(m/p);
            while((p*b<a*V[qq]||p>V[qq])&&qq>0)qq--;
            int q=V[qq];
            if(p*b<a*q||p>q)continue;
            if(ans.fir*ans.sec<p*q){
                ans=MP(p,q);
            }
        }
        cout<<ans.fir<<" "<<ans.sec<<endl;
    }
}

Measured memory_bytes: 3316
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
t=0
#aaは目印（本の数−１）
aa=n-1
for i in range(n):
    t+=a[i]
    if t>k:
        aa=i-1
        t-=a[i]
        break
ans=[aa+1]
f=aa+1
s=0
for i in range(m):
    t+=b[i]
    f+=1
    while t>k:
        if aa<0:
            s=1
            f-=1
            break
        else:
            t-=a[aa]
            aa-=1
            f-=1
    ans.append(f)
    if s==1:
        break

print(max(ans))

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

class UnionFind {
    std::vector<int> p;

public:
    UnionFind(int n) : p(n, -1) {}

    int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

    bool same(int x, int y) { return root(x) == root(y); }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (p[y] < p[x]) std::swap(x, y);
        if (p[x] == p[y]) --p[x];
        p[y] = x;
        return true;
    }
};

void solve(long long N, long long M, std::vector<long long> X,
           std::vector<long long> Y, std::vector<long long> Z) {
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        uf.unite(X[i] - 1, Y[i] - 1);
    }
    int ans = 0;
    for(int i = 0 ; i < N ; i++){
        ans += uf.root(i) == i;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    std::vector<long long> Z(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &Y[i]);
        scanf("%lld", &Z[i]);
    }
    solve(N, M, std::move(X), std::move(Y), std::move(Z));
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,a,b; cin >> n >> a >> b;
  cout << n / (a+b) * a + min(a, n%(a+b)) << endl;
  return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	ll a,b,c,d;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	ll x=a;
	cout << a;
	rep(i,0,2){
		rep(j,0,2){
			rep(k,0,2){
				if(i==0) x+=b;
				else x-=b;

				if(j==0) x+=c;
				else x-=c;

				if(k==0) x+=d;
				else x-=d;

				if(x==7){
					if(i==1) cout << "-" << b;
					if(i==0) cout << "+" << b;

					if(j==1) cout << "-" << c;
					if(j==0) cout << "+" << c;

					if(k==1) cout << "-" << d << "=7";
					if(k==0) cout << "+" << d << "=7";

					//trace4(i,j,k,x);
					return 0;
				}
				else{
					x=a;
				}
				//trace1(x);
			}
		}
		x=a;
	}
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


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

    ll a,b;
    cin>>a>>b;
    b--;
    a--;
    ll val=b/a;
    if(b%a!=0)
    {
        val++;
    }
    cout<<val;
    return 0;
}

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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int ans = H * W;
    ans -= h * W; 
    if (ans > 0) {
        ans -= w * (H - h);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
PY=[[list(map(int,input().split())),i] for i in range(M)]
PY.sort()
cnt=[0 for i in range(N+1)]
ans=[]
for i in range(M):
    cnt[PY[i][0][0]]+=1
    ans.append([PY[i][1],str(PY[i][0][0]).zfill(6)+str(cnt[PY[i][0][0]]).zfill(6)])
ans.sort()
for i in range(M):
    print(ans[i][1])


Measured memory_bytes: 54508
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n,m;cin>>n>>m;
	cout << (n-1)*(m-1) << endl;
}


Measured memory_bytes: 256
n, m ,k = gets.strip.split.map(&:to_i)
A = gets.strip.split.map(&:to_i)
B = gets.strip.split.map(&:to_i)

a = [0]
b = [0]

A.each_with_index do |n, i|
  a << a[i] + n
end

B.each_with_index do |n, i|
  b << b[i] + n
end

list = 0
j = m

0.upto(n) do |i|
  if a[i] > k
    break
  end

  while b[j] > k - a[i] do
    j -= 1
  end

  c = i + j
  list = c if c > list
end

puts list

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

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

	ll ans = 0, m = N;
	for (int i = 1; i < m; ++i) {
		m = N / i - 1;
		int div = N / m, rem = N % m;
		if (div == rem) ans += m;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}
ll fact(ll n)
{
    ll res=1;
    fo1(i,n)
    {
        res=((res%mod)*(i%mod))%mod;
    }
    return res;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

            ll n,m,ans=0;
            cin>>n>>m;
            if(abs(n-m)==1)
                ans=(fact(n)*fact(m))%mod;
            else if(n==m)
                ans=(2*fact(n)*fact(n))%mod;
            else
                ans=0;
            cout<<ans<<endl;
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d %d" , &n , &m);
    cout << (n + m - 1) / m << endl;

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

int main(){
  int a,b,c,d;
  int count = 0;
  
  cin >>a>> b>>c>> d;
  
  for(int r=0; r <= d; r++)
  {
    for(int g=0; g <= d; g++)
	{
      if(d - r * a - g * b < 0)
        continue;
      if((d - r * a - g * b) % c == 0){
        count++;
        continue;
      }
    }
  }

  cout << count << endl;

}

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<long long int>> students(N, vector<long long int>(2));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 2; j++)
    {
      cin >> students.at(i).at(j);
    }
  }
  vector<vector<long long int>> check_points(M, vector<long long int>(2));
  for (int i = 0; i < M; i++)
  {
    for (int j = 0; j < 2; j++)
    {
      cin >> check_points.at(i).at(j);
    }
  }
  for (int i = 0; i < N; i++)
  {
    int ans = -1;
    long long int min_d = 10000000000000;
    for (int j = 0; j < M; j++)
    {
      long long int d = abs(students.at(i).at(0) - check_points.at(j).at(0)) + abs(students.at(i).at(1) - check_points.at(j).at(1));
      if (d < min_d)
      {
        min_d = d;
        ans = j;
      }
    }
    cout << ans + 1 << endl;
  }
}


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

using namespace std;

typedef long long ll;

int main() {
    int n, k;  cin >> n >> k;
    ll r, s, p; cin >> r >> s >> p;
    string c;   cin >> c;
    
    vector<int> f;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (i-k >= 0 && c[i] == c[i-k]) {
            auto ite = lower_bound(f.begin(), f.end(), i-k);
            if (ite != f.end() && *ite == i-k) {
                if (c[i] == 'r')
                    ans += p;
                else if (c[i] == 's')
                    ans += r;
                else 
                    ans += s;
            }
            else 
                f.push_back(i);
        }
        else {
            if (c[i] == 'r')
                    ans += p;
                else if (c[i] == 's')
                    ans += r;
                else 
                    ans += s;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int H1, M1, H2, M2, K; std::cin >> H1 >> M1 >> H2 >> M2 >> K;
  int H = H2 - H1;
  int M = H * 60 + (M2 - M1);
  std::cout << M - K << std::endl;
  return 0;
}



Measured memory_bytes: 3636
N = int(input().rstrip())
l = list(map(int, input().rstrip().split()))
#l = list(set(l))
l.sort(reverse=True)
num = 0
for i in range(len(l) - 2):
	for j in range(i + 1, len(l) - 1):
		if l[i] == l[j]:
			continue

		for k in range(j + 1, len(l)):
			if l[j] == l[k]:
				continue

			if l[i] < (l[j] + l[k]):
				num += 1

print(num)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    for(int i=1; i<=n; i++){
        int x = (int)(1.08*i);
        if (x==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1e5+10,MOD=1e9+7;
int plu(int x,int y){return (1LL*x+y)-(1LL*x+y>=MOD?MOD:0);}
namespace BIT{/*{{{*/
	int c[N*2];
	int mx;
	void init(int _n){mx=_n;}
	void insert(int x,int delta){for (;x<=mx;x+=x&-x) c[x]=plu(c[x],delta);}
	int query(int x){
		if (x<=0) return 0;
		int ret=0;
		for (;x;x-=x&-x) ret=plu(ret,c[x]);
		return ret;
	}
}/*}}}*/
struct Dot{
	int x,y;
	Dot(){}
	Dot(int x1,int y1){x=x1; y=y1;}
	friend bool operator < (Dot x,Dot y){return x.x==y.x?x.y<y.y:x.x<y.x;}
	friend bool operator == (Dot x,Dot y){return x.x==y.x&&x.y==y.y;}
}d[N];
int lis[N*2];
int a[N],b[N];
int f[N*2];
int n,m,cnt;
void prework(){
	int nxt,pre;
	cnt=0;
	for (int i=1;i<=n;++i){
		if (a[i]<b[1]) continue;
		if (a[i]>b[m]) break;
		nxt=lower_bound(b+1,b+1+m,a[i])-b;
		if (a[i]==b[nxt]) continue;
		pre=nxt-1;
		d[++cnt]=Dot(a[i]-b[pre],b[nxt]-a[i]);
		lis[++lis[0]]=a[i]-b[pre];
		lis[++lis[0]]=b[nxt]-a[i];
	}
	sort(lis+1,lis+1+lis[0]);
	lis[0]=unique(lis+1,lis+1+lis[0])-lis-1;
	for (int i=1;i<=cnt;++i){
		//printf("%d %d\n",d[i].x,d[i].y);
		d[i].x=lower_bound(lis+1,lis+1+lis[0],d[i].x)-lis;
		d[i].y=lower_bound(lis+1,lis+1+lis[0],d[i].y)-lis;
	}
	BIT::init(lis[0]);
}
void dp(){
	sort(d+1,d+1+cnt);
	cnt=unique(d+1,d+1+cnt)-d-1;
	memset(f,0,sizeof(f));
	int now=1,ans=1;
	for (int i=1;i<=cnt;++i){
		while (d[now].x<d[i].x) BIT::insert(d[now].y,f[now]),++now;
		f[i]=plu(1,BIT::query(d[i].y-1));
		ans=plu(ans,f[i]);
		//printf("%d %d %d\n",d[i].x,d[i].y,f[i]);
	}
	printf("%d\n",ans);
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	for (int i=1;i<=m;++i) scanf("%d",b+i);
	prework();
	dp();
}


Measured memory_bytes: 3712
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
#define f first
#define s second
using namespace std;
/* 
                            +777777777?
                           7$.I77777III777:
                           7:I?I777777777
                           777777777777,
                           $
                           $
               7$$$$$$7....$..,I$$$$$$$$I7
             7$$$$$$$$$$$$$$$$$$$$$$$$$$$$I
           I$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$I
          7$$$$$$$$$$$$$$$$$$$$$$$7$7$$$$$$$I
          I$$$$$$$$$$$$$$$$$$$$$$$$$7$$$$$$$$I
         I$$$OOOOOOOOZ$$$$$$$$$$$$OOOOOOOOZ$$I
         I$$$OOO$$$$$$$ZOOOOOOOOZ$$$$7$ZOO8$$I
         I$$$$O$$$O  O$$$OOZOO$$$$O  O$$$OO$$$I    $
          $$$$O$$$8OOO$$$O$$$O$$$ZOO$7$$O$$$$I   $$$$
          I$$$$Z$$$ZZ$$$$O$$$$O$$$ZZ$$$$O$$$$    $$$$7
          7$$$$ZO$$$$$$OO$$$$$$O$$$$$$$O$7$$I  I$
           I$$$$$ZZOOZZ$$$$$$$$$$ZOOZZZ7$$$$.I7
          I$$$$$$$$$$--$$OO:7O$$$$$--$$$$$$7$
        $$..:$$$$$$$$\$$$$$Z$$$$$$$/$$$$$$$
        $$ ...$$$$$$$$-------------$$$$$$I
         $+Z$$$7$$$$$$$$$$$$$$$$$$$$$$$$+
            $$$$,I$$$$$$$$$$$$$$$$$$$$$I
                  I$$$$$$$$$$$$$$$$$$~
                    I$$$$$$$$$$$$$$:
                       $        $
                       $        $
                      =,        :
                    ++77        77++
*/
int main(){
  int n;
  cin>>n;
  while(n--){
    unsigned long long a,b,c,d,now,x;
    cin>>a>>b>>c>>d;
    if(d<b || a<b || a%b>c){
      cout<<"No"<<endl;
    }
    else{
      /*int*/ x=__gcd(b,d);//int???
      now=(a-b)-(a-b)%x+x;
      if(a-now<=c)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char buf[20];

int main() {
  scanf("%s", buf);
  ll ret = 0;
  int len = strlen(buf);
  for(int mask = 0; mask < (1 << (len-1)); mask++) {
    ll val = 0;
    for(int i = 0; i < len; i++) {
      val *= 10;
      val += buf[i] - '0';
      if(mask&(1<<i)) {
        ret += val;
        val = 0;
      }
    }
    ret += val;
  }
  printf("%lld\n", ret);
}


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

int n, m, k, card[201], buf[201], buf2[201];


int makeb(int k) {
	for (int i = 0; i < k; i++) {
		buf[i] = card[i];
	}
	for (int i = k; i < 2 * n; i++) {
		buf2[i - k] = card[i];
	}
	return 0;
}

int cut(int k) {
	makeb(k);
	int r = 2 * n - k;
	for (int i = 0; i < r; i++) {
		card[i] = buf2[i];
	}
	for (int i = r; i < 2 * n; i++) {
		card[i] = buf[i - r];
	}
	return 0;
}

int shuf() {
	makeb(n);
	for (int i = 0; i < n; i++) {
		card[2 * i] = buf[i];
		card[2 * i + 1] = buf2[i];
	}
	return 0;
}

int main(){
	scanf("%d", &n);
	scanf("%d", &m);
	for (int i = 0; i < 2 * n; i++) {
		card[i] = i + 1;
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &k);
		if (k == 0) {
			shuf();
		}
		else {
			cut(k);
		}
	}

	for (int i = 0; i < 2 * n; i++) {
		printf("%d\n", card[i]);
	}

	return 0;
}

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

int main() {
    int n;cin>>n;
    int a[n],cc,ans=1;
    cin>>a[0];
    cc=a[0];

    for(int i=1;i<n;++i){
        cin>>a[i];
        if(a[i]>=cc)ans+=1;
        cc=max(cc,a[i]);
    }
    cout<<ans<<endl;
	return 0;
}

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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 2e5 + 10;

int n;
char s[N];

int main(){
    while(~scanf("%s", s)){
        n = strlen(s);
        if(n <= 2){
            puts("0");
            continue;
        }
        LL ans = 0;
        int pre = 0;
        if(s[0] == 'A' && s[1] == 'B'){
            pre = 1;
        } else if(s[0] == 'A' && s[1] == 'A'){
            pre = 2;
        } else if(s[1] == 'A'){
            pre = 1;
        }
        for(int i=2; i<n; i++){
            if(s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C'){
                ans += pre;
                s[i-2] = 'B';
                s[i-1] = 'C';
                s[i] = 'A';
            } else {
                if(s[i] == 'A'){
                    if(s[i-1] == 'A'){
                        pre++;
                    } else {
                        pre = 1;
                    }
                } else if(s[i] == 'B'){
                    if(s[i-1] != 'A')   pre = 0;
                } else {
                    pre = 0;
                }
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

using namespace std;

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	int mn = min(b, d);
	int mx = max(a, c);
	printf("%d\n", max(0, mn - mx));

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<string>
#include<sstream>
#include<math.h>
using namespace std;
//char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main(){

		int n;cin>>n;char a[n];memset(a,'\0',sizeof(a));
		cin>>a;
		int x=0;int ans=-1;
		for(int i=0;i<n;i++){
			if(a[i]=='I'){x++;}else x--;
			ans=max(x,ans);
		}
		if(ans<0) cout<<0<<endl; else
		cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>


using namespace std;

const int MaxN = 1e5 + 5;

long long dp[MaxN];
int w[105] , W , n;
long long v[105];

int main(){
	cin >> n >> W;
	for(int i = 1; i <= n ; i++)cin >> w[i] >> v[i];
	for(int i = 1; i <= n ; i++){
		for(int j = W ; j >= w[i] ; j--)dp[j] = max(dp[j] , dp[j - w[i]] + v[i]);
	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    int ans = N;
    REP(i,M) {
        int a; cin >> a;
        ans -= a;
    }
    ans = max(ans,-1);
    cout << ans << '\n';

    return 0;
}

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

int S[10000],A[500];
int 	linearSearch(int,int);

int main() {
	int n,i,q,k=0,aa,p=0;
	int T[500];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		scanf("%d",&S[i]);
		}
		scanf("%d",&q);
		
		for(i=0;i<q;i++) {
			scanf("%d",&T[i]);
			}
			
			for(i=0;i<q;i++) {
			aa=linearSearch(T[i],n);
			if(aa==1) p++;
			n++;
		}	
		printf("%d\n",p);
		return 0;
}
		
		
	int 	linearSearch(int key, int n) {
int i = 0;
   S[n] = key;
  while (S[i]!=key) { 	
     i++; 
   }
    if (i==n) {
     return 0;
    }
        return 1;
        }


Measured memory_bytes: 2084
//ThakurAnurag
//TemplateCode

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

#define ll long long int
#define ull unsigned long long int
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define fo2(i,a,n) for(ll i=n;i>=a;i--)
#define endl "\n"
#define sp " "
#define f first
#define s second
#define pb push_back
#define buffer ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define init(arr,val) memset(arr,val,sizeof(arr))
#define vecl(v) vector<ll> v
#define vecs(v) vector<string> v
#define vecp(v) vector < pair <ll,ll> > v

int main()
{
	ll n,m;
	cin>>n>>m;

	if(m>=2*n && m<=4*n && m%2==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
 
signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	vector<lli> s(n+1);
	s[0] = 0;
	for(lli i=0;i<n;i++){
		s[i+1] = s[i]+a[i];
	}
	sort(s.begin(),s.end());

	lli ans=0;
	lli before=-INF;
	map<lli,lli> cnt;
	for(lli i=0;i<n+1;i++){
		cnt[s[i]]++;
	}

	for(auto e:cnt){
		ans += (e.second)*(e.second-1)/2;
	}
	cout<<ans<<endl;
 
	return 0;
}

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

long long N;
map<string, long long> str_count;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		string s;
		cin >> s;
		vector<char> tmp;
		for(int j = 0; j < s.size(); j++){
			tmp.push_back(s[j]);
		}
		sort(tmp.begin(), tmp.end());
		string sorted = "";
		for(int j = 0; j < tmp.size(); j++){
			sorted += tmp[j];
		}
		str_count[sorted]++;
	}


	long long ans = 0;
	for( auto i = str_count.begin(); i != str_count.end() ; ++i ) {
		if(i->second > 1){
			ans += (i->second) * (i->second - 1)/2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 12800
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define srt(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
bool is_prime[1000001];
VLL primes;
void seive()
{
	LL maxN = 1000001;
	is_prime[0]=true;
	is_prime[1]=true;
	
	for(LL i=2; i*i<=maxN; i++)
	{
		if(!is_prime[i])
		{
			for(LL j=i*i; j<=maxN; j+=i)
				is_prime[j]=true;
		}
	}
	for(LL i=2; i<=maxN; i++)
	{
		if(!is_prime[i])primes.pb(i);
	}
}

 
LL binpow(LL a, LL b, LL c)
{
	a %= c;
	LL res = 1 ;
	while(b > 0){
		if(b & 1)
		res = res * a % c ;
		a = a * a % c ;
		b >>= 1;
		//cout<<res<<endl;
	}
	return res;
}
 
LL mod = 1e9+7;


 
int main()
{
	ios_base::sync_with_stdio(false);
	//seive();

	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
		LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		//LL aa[10000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0, ans=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivl, low, up;
		set<LL> :: iterator it;
		VP :: iterator ivp;
		
		
		cin>>str;
		if(str=="RRR")cout<<3<<endl;
		else if(str[0]=='R' && str[1]=='R')cout<<2<<endl;
		else if(str[0]=='R'&& str[2]=='R')cout<<1<<endl;
		else if(str[1]=='R' && str[2]=='R')cout<<2<<endl;
		else if(str[1]=='R')cout<<1<<endl;
		else if(str[0]=='R')cout<<1<<endl;
		else if(str[2]=='R')cout<<1<<endl;
		else cout<<0<<endl;
			
			
	//}
	exit()
 
 
}


Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
	int max, min, n, i, num[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&num[i]);

	min=num[0];
	max=-100000000000;

	for (i = 1; i < n; ++i)
		{
			if (max<num[i]-min)max=num[i]-min;
			if (min>num[i])min=num[i];
			
		}	
	printf("%d\n",max);	
	return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    A--, B--, C--, D--;

    string ans = "No";
    if ( C < D ) {
        bool check = true;
        for (int i = A; i < C; i++) {
            if ( S[i] == '#' && S[i+1] == '#' ) {
                check = false;
                break;
            }
        }
        if ( check ) {
            for (int i = B; i < D; i++) {
                if ( S[i] == '#' && S[i+1] == '#' ) {
                    check = false;
                    break;
                }
            }
        }
        if ( check ) {
            ans = "Yes";
        }
    } else {
        bool check = true;
        for (int i = A; i < max(C, D); i++) {
            if ( S[i] == '#' && S[i+1] == '#' ) {
                check = false;
                break;
            }
        }
        
        if ( check ) {
            for (int i = B-1; i <= D-1; i++) {
                if ( S[i] == '.' && S[i+1] == '.' && S[i+2] == '.' ) {
                    ans = "Yes";
                    break;
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    sort(x.begin(), x.end());

    vector<int> diff(m-1);
    for (int i = 0; i < m - 1; ++i) {
        diff[i] = x[i+1] - x[i];
    }

    sort(diff.begin(), diff.end());

    int ans = 0;
    for (int i = 0; i < m-1-(n-1); ++i) {
        ans += diff[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <array>
#include <map>
#include <string>

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

using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h.at(i);

	sort(h.begin(), h.end());

	int ans = h.at(n - 1);
	for (int i = 0; i < n - k + 1; i++)
	{
		ans = min(h.at(i + k - 1) - h.at(i), ans);
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<stdio.h>
int main()
{
	int a, b, c, d, e,g;
	cin >> a >> b >> c >> d >> e;
	if (a >= 1)
	{
		g = (b - a)*e;
		cout << g << endl;
	}
	else
	{
		if (a < 0)
		{
			g = -a*c + d + b*e;
			cout << g << endl;
		}
		else
		{
			g = d + b*e;
			cout << g << endl;
		}
	}
	return 0;
}

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

int N, Y;

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

  int a = -1;
  int b = -1;
  int c = -1;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= N - i; j++)
    {
      int total = 10000 * i + 5000 * j + 1000 * (N - i - j);
      if (total == Y)
      {
        a = i;
        b = j;
        c = N - i - j;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256