akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define mod 1000000007
using namespace std;
void solve()
{	
	int n;cin>>n;
	vll a(n);
	f(i,0,n-1)cin>>a[i];
	ll sum=0;
	vll suf(n+1);
	suf[n-1]=a[n-1];
	for(int i=n-2;i>=0;--i){
		suf[i]=(suf[i+1]%mod+a[i]%mod)%mod;
	}
	f(i,0,n-2){
		sum=(sum%mod + (a[i]%mod*(suf[i+1]%mod))%mod)%mod;
	}
	cout<<sum<<'\n';

}
int main()
{	Fast;
//	int t;cin>>t;
//	while(t--)
	solve();
}

Measured memory_bytes: 6332
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<sstream>
#include<cctype>
#include<cmath>
#include<algorithm>
using namespace std;

#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define repp(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define clr(a) memset((a), 0 ,sizeof(a))


typedef pair<int,int> P;
typedef vector<pair<int,int> > pii;
typedef map<string,int> mi;


int A[111];
int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<k;i++){
		cin >> A[i];
	}
	bool ok;
	for(int i=n;;i++){
		ok=true;
		int a=i;
		while(a){
			int x=a%10;
			for(int j=0;j<k;j++){
				if(x==A[j]){
					ok=false;
					break;
				}
			}
			if(!ok)break;
			a/=10;
		}
		if(ok){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
bef = gets.split.map(&:to_i)
1.upto(2) do
  aft = gets.split.map(&:to_i)

  d = aft[0] - bef[0]
  1.upto(2) do |j|
    if aft[j] - bef[j] != d
      puts "No"
      exit
    end
  end

  bef = aft
end

puts "Yes"


Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main() {

	int i,k;
	int num;
	long long min, max,sum;

	scanf("%d", &i);
	scanf("%d", &num);
	sum = num;
	min = num;
	max = num;
	
	for(k=1;k<i;k++){
		scanf("%d", &num);
		sum = sum+num;
		if (min > num) {min = num;}
		if (max < num) {max = num;}
	
	}

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

	return 0;

}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    
     string c,d;
     cin>>c>>d;
     if(c[0]==d[2]&&c[1]==d[1]&&c[2]==d[0]){
        cout<<"YES" <<endl;
     }
     else
        cout<<"NO" <<endl;
    
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

bool cmp(int x,int y){
    return abs(0-x)<abs(0-y);
}

//各桁の合計
int split_sum(int i){
    string s=to_string(i);
    int sum=0;
    for(auto item:s){
        sum+=item-'0';
    }
    return sum;
}

signed main(){
    CIN(X);
    int fx=split_sum(X);
    printf(X%fx==0?"Yes":"No");

    return 0;
}

Measured memory_bytes: 256
N = int(input())
num = list(map(int, input().split()))
dict = {}
for i in range(0, N):
    if num[i] in dict:
        dict[num[i]] += 1
    else:
        dict[num[i]] = 1
totalNum = 0
for i in range(1, N + 1):
    if i in dict and dict[i] > 1:
        totalNum += ((dict[i] * (dict[i] - 1)) / 2)
for i in range(0, N):
    if dict[num[i]] > 1:
        print(int(totalNum - dict[num[i]] + 1))
    else:
        print(int(totalNum))

Measured memory_bytes: 26140
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
acc = 1
b = [0,0,0]
for i in range(n):
    cnt = 0
    done = False
    for j in [0,1,2]:
        if a[i]==b[j]:
            cnt += 1
            if not done:
                b[j] += 1
                done = True
    acc = (acc * cnt) % R
print(acc)


Measured memory_bytes: 52952
N = int(input())
A = [int(input()) for _ in range(N)]
A.append(A[N-1])

ans = 0
for i in range(N-1, -1, -1):
    if A[i] > i or A[i+1]-A[i] >= 2:
        print(-1)
        exit()
    elif A[i+1]-A[i] == 1:
        continue
    else:
        ans += A[i]
print(ans)


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

int main() {
  
  int a;
  cin >> a;
  
  if(a==1) cout << "Hello World" << endl;
  else {
    int b,c;
    cin >> b >> c;
    cout << b+c << endl;
  }
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  in(n);
  vector<ll> c(n);
  rep(i, n)
    in(c[i]);
  a = 0;
  rep(i, n - 1){
    if(c[i] - 1 == c[i + 1])
      c[i + 1]++;
    else if(c[i] - 1 > c[i + 1]){
      a = 1;
      break;
    }
  }
  if(a == 0)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int totcap;
int dp[30000];
double des;
int main() {
    int a, b, c, d, e;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &totcap);
    int ans;
    des = -100000000.0;
    int answ = 0, anst = 0;
    for (int i = 0; i <= totcap / (a * 100); i++) {
        for (int j = 0; j <= totcap / (b * 100); j++) {
            memset(dp, 0, sizeof(dp));
            int water = i * 100 * a + j * 100 * b;
            if (water <= totcap) {
                int cap = i * a * e + j * b * e;
                int ret = 0;
                for (int j = c; j <= cap; j++) {
                    dp[j] = max(dp[j - c] + c, dp[j]);
                    if (dp[j] + water <= totcap)
                        ret = max(ret, dp[j]);
                }
                for (int j = d; j <= cap; j++) {
                    dp[j] = max(dp[j - d] + d, dp[j]);
                    if (dp[j] + water <= totcap)
                        ret = max(ret, dp[j]);
                }
                ans = ret;
                if (water != 0) {
                    double temp = (double) ans / (double) (water + ans);
                    if (temp > des) {
                        des = temp;
                        answ = water + ans;
                        anst = ans;
                    }
                }
            }
        }
    }
    printf("%d %d\n", answ, anst);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
ll a[100005];
rep(i,0,n-1)cin>>a[i];
if(a[n-1]>2)
{
	ol("-1");
	return 0;
}
ll lo=2,hi=1e18+7,mid,mn=-1;

while(lo<=hi)
{
	mid=(lo+hi)/2;
	ll s=mid;
	rep(i,0,n-1)
	{
		s=s-s%a[i];
	}
	if(s>=2)
	{
		if(s==2)
		mn=mid;
		hi=mid-1;
	}
	else
	{
		lo=mid+1;
	}
}

lo=2,hi=1e18+7;
ll mx=-1;

while(lo<=hi)
{
	mid=(lo+hi)/2;
	ll s=mid;
	rep(i,0,n-1)
	{
		s=s-s%a[i];
	}
	if(s<=2)
	{
		if(s==2)
		mx=mid;
		lo=mid+1;
	}
	else
	{
		hi=mid-1;
	}
}
if(mn==-1||mx==-1)
{
	ol("-1");
	return 0;
}
o2(mn,mx);
return 0;
}



Measured memory_bytes: 1024
import math
n = int(input())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0
ave1 = math.floor(sum(a) / n)
ave2 = math.ceil(sum(a) / n)
for i in range(n):
    ans1 += (a[i] - ave1) ** 2
    ans2 += (a[i] - ave2) ** 2
print(min(ans1, ans2))


Measured memory_bytes: 3060
inputs = open(0).readlines()
n, m = map(int, inputs[0].split())
AB = [list(map(int, AB.split())) for AB in inputs[1:]] 
AB.sort()
ans, count = 0, 0
for a, b in AB:
  if count + b >= m:
    ans += a * (m - count)
    break
  count += b
  ans += a * b
print(ans)

Measured memory_bytes: 36076
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

ll MAX = 1e9+ 7;

ll ppow(ll x, ll y){
    ll ans = 1;
    for(ll i = 0;i < y; i++){
        ans *= x;
        ans %= MAX;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    ll all = ppow(10, n);
    all %= MAX;
    DEBUG_VAL("all", all);
    ll nin = ppow(9, n);
    nin %= MAX;
    DEBUG_VAL("nin", nin);
    ll kab = ppow(8, n);
    kab %= MAX;
    DEBUG_VAL("kab", kab);
    ll ans = all - 2*nin + kab;
    ans %= MAX;
    if(ans < 0) ans += MAX;
    cout << ans << endl; 
}


Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc046/tasks/abc046_b

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int n, k;
  long r;

  cin >> n >> k;

  r = k;

  for (size_t i = 1; i < n; i++)
  {
    r *= (k - 1);
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    vector<int> towers;
    towers.push_back(0);
    for(int i=1; i<1000; i++){
        towers.push_back(towers[i-1]+i);
    }
    int d=b-a;
    cout << towers[d-1]-a;
    

    return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int BinarySearch(int x, List<int> xs)
        {
            int N = xs.Count;
            if (N == 0) { return int.MaxValue; }
            int a = 0;
            int b = N - 1;
            if (xs[a] > x) { return xs[0] - 1; }
            if (xs[b] < x) { return int.MaxValue; }
            while (b - a >= 2)
            {
                int i = (a + b) / 2;
                if (xs[i] < x) { a = i; } else { b = i; }
            }
            return xs[b] - 1;
        }
        static int Solve(int H, int W, HashSet<int>[] set, List<int>[] walls)
        {
            int min = H;
            int x = 1;
            int y = 1;
            while (x < H)
            {
                min = Math.Min(BinarySearch(x, walls[y]), min);
                if (y == W) { break; }
                do { ++x; } while (x < H && set[y + 1].Contains(x));
                ++y;
            }
            return min;
        }
        static void Main(string[] args)
        {
            int[] V1 = ReadInts();
            int H = V1[0];
            int W = V1[1];
            int N = V1[2];
            var set = new HashSet<int>[W + 1];
            var walls = new List<int>[W + 1];
            for (int i = 1; i <= W; ++i)
            {
                set[i] = new HashSet<int>();
                walls[i] = new List<int>();
            }
            for (int i = 0; i < N; ++i)
            {
                int[] V2 = ReadInts();
                int X = V2[0];
                int Y = V2[1];
                set[Y].Add(X);
                walls[Y].Add(X);
            }
            for (int i = 1; i <= W; ++i) { walls[i].Sort(); }
            Console.WriteLine(Solve(H, W, set, walls));
        }
    }
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);

const int N = 2e5 + 10;

#define FILENAME ""

int n;
int k;

int dp[N], h[N];

void fdp() {
	for (int i = n - 1; i >= 1; i--) {
		for (int j = 1; j <= k; j++) {
			if (i - j < 0) break;
			dp[i - j] = min (dp[i - j], dp[i] + abs (h[i] - h[i - j]));
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen(FILENAME ".in", "r", stdin);
//	freopen(FILENAME ".out", "w", stdout);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		dp[i] = inf;
	}
	dp[n - 1] = 0;
	fdp();
	cout << dp[0];
	



	re 0;
}     







Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    int N=S.length();
    ll ans=0;
    rep(i,N/2){
        if(S[i]!=S[N-1-i]) ++ans;
    }
    cout<< ans<<"\n";
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}





///////////////////////////




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

	ll ans = 0;

	for (char i : S) {
		if (i == '+') { ans++; }
		else { ans--; }
	}

	cout << ans;

	system("PAUSE");

}


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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 123;
int k, n, a[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> k >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = k - a[n] + a[1];
	for (int i = 2; i <= n; i++) {
		ans = max(ans, a[i] - a[i - 1]);
	}
	cout << k - ans;
}


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

typedef unsigned long long ull;

class RollingHash{
private:
	const ull B = 100000007;
	vector<ull>P;
	vector<ull>H;
	string s;
public:
	RollingHash(string _s){
		s = _s;
		P.push_back(1);
		H.push_back(0);
		for(int i=1;i<=s.size();i++){
			P.push_back(P[i-1] * B);
			H.push_back(H[i-1] * B + s[i-1]);
		}
	}
	ull Get(int l, int r){
		return H[r] - H[l] * P[r-l];
	}
};

int main(){
	
	int n, m;
	cin>>n>>m;
	string s;
	cin>>s;
	RollingHash rh(s);
	set<ull>S;
	int l = 0, r = 1;
	for(int i=0;i<m;i++){
		string q;
		cin>>q;
		if(q=="L++")l++;
		if(q=="L--")l--;
		if(q=="R++")r++;
		if(q=="R--")r--;
		S.insert(rh.Get(l, r));
	}
	cout<<S.size()<<endl;
	
	
	return 0;
}


Measured memory_bytes: 22240
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod2 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

int main()
{
    int n;
    cin >> n;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        if(s=="AC")
            a+=1;
        else if(s=="WA")
            b+=1;
        else if(s=="TLE")
            c+=1;
        else if(s=="RE")
            d+=1;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
signed main() {
  int n, m;
  cin >> n >> m;
  if (n == m) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
  vi p(n);
  rep (i, n) {
    cin >> p[i];
  }
  int mi = inf;
  int ans = 0;
  rrep (i, n) {
    if (p[i] <= mi) ans++;
    chmin(mi, p[i]);
  }
  cout<< ans << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

a_abs = [abs(x) for x in a]
abs_max_index = a_abs.index(max(a_abs))
abs_max = a[abs_max_index]
print(2*N)
for i in range(N):
    print('{} {}'.format(abs_max_index+1,i+1))
if abs_max >= 0:
    print('{} {}'.format(abs_max_index+1,1))
    for i in range(1,N):
        print('{} {}'.format(i,i+1))
else:
    print('{} {}'.format(abs_max_index+1,N))
    for i in range(N-1):
        print('{} {}'.format(N-i,N-i-1))

Measured memory_bytes: 3064
PROGRAM-ID.                      ABC_106_C.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 S1.
        03 S PIC X(1) OCCURS 100.

    01 N       PIC 9(3).
    01 K       PIC 9(19).

    01 i       PIC 9(19).

PROCEDURE                        DIVISION.
    ACCEPT S1.
    ACCEPT K.

    PERFORM VARYING i FROM 1 BY 1 UNTIL K < i
        IF FUNCTION STORED-CHAR-LENGTH(S1) < i
            EXIT PERFORM
        END-IF
        IF 1 NOT = S(i)
            DISPLAY S(i)
            STOP RUN
        END-IF
    END-PERFORM.

    DISPLAY '1'
    STOP RUN.


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(int N, int M, int[][] queries)
        {
            var counts = new int[N + 1];
            foreach (var q in queries)
            {
                ++counts[q[0]];
                ++counts[q[1]];
            }
            return counts.All(n => n % 2 == 0);
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            int N = V[0];
            int M = V[1];
            int[][] queries = new int[M][];
            for (int i = 0; i < M; ++i) { queries[i] = ReadInts(); }
            Console.WriteLine(Solve(N, M, queries) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 21832
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, m = read_int_list()
    res = (n - 1) * (m - 1)
    print(res)

main()


Measured memory_bytes: 2940
#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 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 p = 2019;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> d(n+1);
    int ten = 1;
    for(int i = n-1; i >= 0; i--){
        int a = (s[i] - '0') * ten % p;
        d[i] = (d[i+1]+a) % p;
        ten *= 10;
        ten %= p;
    }
    vector<int> cnt(p);
    ll ans = 0;
    for(int i = n; i >= 0; i--){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;

int dx[5]={-2,-1,0,+1,+2},dy[5]={-2,-1,0,+1,+2};
int n,m,r1,c1,r2,c2,dp[1005][1005];
string s[1005];


void solve(){
    cin>>n>>m>>r1>>c1>>r2>>c2;
    rep(i,0,n) cin>>s[i];
    rep(i,0,n) rep(j,0,m) dp[i][j]=LLONG_MAX;
    r1--;r2--;c1--;c2--;
    dp[r2][c2]=0;


    priority_queue<pair<int,pair<int,int>>> q;

    q.push(mp(0,mp(r2,c2)));

    while(sz(q)){
        auto d=-q.top().x;
        auto pos=q.top().y;
        q.pop();

        rep(i,0,5){
            rep(j,0,5){
                if(!dx[i] and !dy[j]) continue;

                int x=dx[i]+pos.x;
                int y=dy[j]+pos.y;
                if(x<0 or y<0 or x>=n or y>=m or s[x][y]=='#') continue;
                

                if((abs(dx[i])==1 and !dy[j]) or (abs(dy[j])==1 and !dx[i])){
                    if(dp[x][y]>d){
                        dp[x][y]=d;
                        q.push(mp(-d,mp(x,y)));
                    }
                }
                else{
                    if(dp[x][y]>d+1){
                        dp[x][y]=d+1;
                        q.push(mp(-d-1,mp(x,y)));
                    }
                }
            }
        }
    }

    if(dp[r1][c1]==LLONG_MAX) cout<<-1;
    else cout<<dp[r1][c1];
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 12628
N = int(input())
A = [list(map(int, input().strip().split())) for _ in range(2)]

if N ==1:
    print(A[0][0] + A[1][0])
else:
    print(max([sum(A[1][down:]) + sum(A[0][:down+1]) for down in range(N-1)]))

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int M = 1e5 + 10;
typedef long long ll;
ll a[M] , sum[M];
int main() {
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++) {
        cin >> a[i];
    }
    sort(a , a + n);
    sum[0] = a[0];
    int pos = 0;
    for(int i = 1 ; i < n ; i++) {
        if(sum[i - 1] * 2 < a[i]) pos = i;
        sum[i] = sum[i - 1] + a[i];
    }
    cout << n - pos << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 2333
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, c;
int main() {
	n = read(), m = read(), c = read();
	rep(i, 1, m) printf("%d ", c);
	if(c == 1000000000) rep(i, 1, n - m) printf("1 "); 
	else rep(i, 1, n - m) printf("%d ", c + 1); 
	return 0;
}


Measured memory_bytes: 1280
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    ans = N/(A + B)*A;
    //cout << ans << endl;
    N = N%(A + B);
    if(A >= N){
        ans += N;
    }else{
        ans += A;
    }
    cout << ans << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
x, y = map(int, input().split())
ans = float('inf')
if x <= y:
    ans = min(ans, y - x)
if (-1) * x <= y:
    ans = min(ans, y + x + 1)
if x <= (-1) * y:
    ans = min(ans, -y - x + 1)
if (-1) * x <= (-1) * y:
    ans = min(ans, -y + x + 2)
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	int solution[2][N] = {0};
	REP(i, 0, 2){
		REP(j, 0, N){
			cin >> solution[i][j];
			if(i == 0){
				if(j != 0) solution[i][j] += solution[i][j-1];
			}
			else{
				if(j==0) solution[i][j] += solution[i-1][j];
				else solution[i][j] = max(solution[i][j] + solution[i-1][j], solution[i][j] + solution[i][j-1]);
			}
		}
	}
	cout << solution[1][N-1];
	

}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S; cin >> S;
    ll ans = 0;
    ll c = 0;
    REP(i, S.length()) {
        if (S[i] == 'W') {
            ans += (i - c);
            c++;
        }
    }
    cout << ans << "\n";
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int s[111];
bool dp[111111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>s[i];
  dp[0]=true;
  rep(i,n)for(int j=100000;j>=0;j--){
    if(dp[j]&&j+s[i]<100000)dp[j+s[i]]=true;
  }
  int res=0;
  rep(i,100000){
    if(dp[i]&&i%10!=0)res=i;
  }
  cout<<res<<endl;
	return 0;
}


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

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

    vector<char> V(4);

    rep(i, 4)
    {
        cin >> V[i];
    }

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

    if (V[0] == V[1] && V[2] == V[3] && V[1] != V[2])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

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


class Hash{
    public:
    const static long long M=1046527;
    long long lst[M]={};
    Hash(){
    }
long long H(long long key,int i){
    long long h1=key%M;
    long long h2=1+(key%(M-1));
    return (h1+i*h2)%M;
}
void insert(long long key){
    int i=0;
    while(true){
        long long j=H(key,i);
        if(lst[j]==0){
            lst[j]=key;break;
        }
        else{i++;}
    }
}
long long search(long long key){
    int i=0;
    while(true){
        long long j=H(key,i);
        if(lst[j]==key)return j;
        else if(lst[j]==0 || i>=M)return 0;
        else{i++;}
    }
}
};
long long get_id(string x){
    long long ans=0;
    for(int i=0;i<x.size();i++){
        if(x[i]=='A')ans+=1*(pow(10,i));
        else if(x[i]=='C')ans+=2*(pow(10,i));
        else if(x[i]=='G')ans+=3*(pow(10,i));
        else{ans+=4*(pow(10,i));}
    }
    return ans;
}

int main(){
    int n;cin>>n;
    Hash Hah;
    for(int k=0;k<n;k++){
        string order,code;cin>>order>>code;
        long long id=get_id(code);
        if(order=="insert"){
            Hah.insert(id);
        }
        else{
            if(Hah.search(id))cout<<"yes"<<endl;
            else{cout<<"no"<<endl;;}
        }
    }
    return 0;
}


Measured memory_bytes: 11512
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll rui[ohara];

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

  cin >> n;
  ll lim = 1;
  ll curr = 0;
  while (1) {
    rui[cnt] = lim;
    curr += lim;
    lim *= 26;
    cnt++;
    if (curr > n) {
      lim /= 26;
      curr -= lim;
      cnt--;
      break;
    }
  }
  // debug(cnt);
  rrrep(i, cnt - 1, 0) {
    s[i] = 'a';
    rep(j, 26) {
      if (curr + rui[i] * (j + 1) > n) {
        curr += rui[i] * (j);
        s[i] = alph[j];
        break;
      }
    }
  }
  rrrep(i, cnt - 1, 0) cout << s[i];
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
b[i]>a_maxをでかい順に投げる
そのあとa[i]が一番でかいものを振り続ける
*/

ll n,h,a[100010],b[100010],ans=0;

int main(void){
	cin>>n>>h;
	rep(i,n)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	irep(i,n){
		if(b[i]<=a[n-1])break;
		if(h<=0)break;
		h-=b[i];
		ans++;
	}
	if(h>0){
		ans+=h/a[n-1];
		if(h%a[n-1]!=0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int candy = 0;

		for (int i = 1; i <= n; i++) {
			candy += i;
		}
		System.out.println(candy);
	}
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  ll l, r;
  cin >> l >> r;
  
  r = min(r, l + 4038);
  int ans = 3000;
  for(ll i = l; i <= r; ++i) {
    for(ll j = i+1; j <= r; ++j) {
      int res = i*j % 2019;
      ans = min(ans, res);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n,l;
    char **s;
    //char *com;
    //int yoso=0;
    int k;
    k=scanf("%d %d",&n,&l);
    s=calloc(n,sizeof(char*));
    for(int i=0;i<n;i++){
        s[i]=calloc(l+1,sizeof(char));
    }
    for(int i=0;i<n;i++){
      k=  scanf("%s",s[i]);
    }
    //com=calloc(l*n+1,sizeof(char));
    //com[l*n]='\0';
    int min;
    for(int c=0;c<n;c++){
        min=c;
        for(int a=c+1;a<n;a++){
            for(int i=0;i<l;i++){
                int flag=0;
                for(int j=0;j<i;j++){
                    if(s[min][j]==s[a][j]) flag++;
                }
                if((flag==i)&&(s[a][i]<s[min][i])){
                    min=a;
                }
            }
        }/*
        for(int i=0;i<l;i++){
                com[yoso++]=s[m][i];
        }*/
        printf("%s",s[min]);
        char sss[l+1];sss[l]='\0';
        for(int i=0;i<l;i++){
            sss[i]=s[c][i];
        }
        for(int i=0;i<l;i++){
            s[c][i]=s[min][i];
        }
        for(int i=0;i<l;i++){
            s[min][i]=sss[i];
        }
    }
    //printf("%s",com);

    free(s);
  //  free(com);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    int a{},b{},x;  cin>>a>>b>>x;
    int lq{},fq{},d{};
    lq = b/x;
    fq = a/x;
    d = (a%x==0);
    cout<<lq-(fq-d)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

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



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
long long n,h,j,i,x,y,c=0,m,p;
cin>>n>>h;
vector<long long>a;
vector<long long>b(n);
for(i=0;i<n;i++){
        cin>>j;
        a.push_back(j);
}
for(i=0;i<h;i++){
    cin>>m>>p;
    x=m-1;
    y=p-1;
if(a[x]==a[y]){
    b[x]=1;
    b[y]=1;
}
else if(a[x]>a[y]){
    b[y]=1;
}
else{
    b[x]=1;
}
}
for(i=0;i<n;i++){
    if(b[i]==0){
        c++;
    }
}
cout<<c;
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long N;
    cin >> N;

    if (N % 2 == 0) {
        cout << (N / 2) * (N - 1) << "\n";
    } else {
        cout << N * ((N - 1) / 2) << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        var a = ReadInt(n).OrderByDescending(x => x).ToArray();
        var que = new Queue<int>();
        que.Enqueue(a.First());
        long ans = 0;
        foreach (var x in a.Skip(1))
        {
            ans += que.Dequeue();
            que.Enqueue(x);
            que.Enqueue(x);
        }
        Console.WriteLine(ans);
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


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

int main() {
	
	string s,t;
	cin>>s>>t;
	
	for(int i = 0; i < s.size(); i++)
	{
		int l = 0;
		int o = i;
		while(s[i] == t[l] and i < s.size())
		{
			i++;
			l++;
		}
		if(i == s.size())
		{
			int j = 0;
			while(s[j] == t[l] and l <= t.size())
			{
				j++;
				l++;
			}
		}
		if(l == t.size())
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3632
H,W = map(int,input().split())
N = int(input())
L = list(map(int,input().split()))
A = []
for i in range(N) :
    a = [str((i+1))]*L[i]
    A = A + a
for i in range(H) :
    p = A[W*i:W*(i+1)]
    if i % 2 != 0 :
        p = list(reversed(p))
    ans = " ".join(p)
    print(ans)
    

Measured memory_bytes: 3828
using System;
using System.Linq;
namespace B___Greedy_Takahashi
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Trim().Split(' ').Select(n => long.Parse(n)).ToArray();
            var A = input[0];
            var B = input[1];
            var K = input[2];
            if (K < A)
            {
                A = A - K;
                K = 0;
            }
            else
            {
                B = Math.Max(0, B - (K - A));
                A = 0;
            }
            Console.WriteLine(A + " " + B);
        }
    }
}


Measured memory_bytes: 13524
main :: IO ()
main = do
  ss <- fmap (fmap (fmap (read :: String -> Int)) . fmap words . lines)
          getContents
  mapM_ putStrLn $ map func ss

func :: [Int] -> String
func ss = calc ss [] ""

calc :: [Int] -> [Int] -> String -> String
calc [0,q] _ s = s
calc [p,q] save s
  | p `div` q > 0 = calc [p - (p `div` q) * q, q]
                         (save ++ [p - (p `div` q) * q])
                         s
  | elem p save = s ++ "\n" ++ (repeats p save)
  | otherwise = calc [p*10 - (p*10 `div` q)*q,q]
                     (save ++ [p])
                     (s ++ (show $ p*10 `div` q))

repeats :: Int -> [Int] -> String
repeats p (x:xs)
  | p == x = replicate ((length xs) + 1) '^'
  | otherwise = ' ':(repeats p xs)

Measured memory_bytes: 4140
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=2e5+5;
int a[maxn];
map<int,int>mp1,mp2;
int main()
{
    int n, i, j;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        int x=a[i]+i;
        if(mp1[x]==0)mp1[x]=1;
        else mp1[x]=mp1[x]+1;
//        x=i-a[i];
//        if(mp2[x]==0)mp2[x]=1;
//        else mp2[x]=mp2[x]+1;
    }
    long long ans=0;
    for(i=1; i<=n; i++)
    {
        int x=i-a[i];
        ans+=mp1[x];
    }
    cout<<ans<<endl;
    return 0;
}
/*
1 0 -1
2 1 -1
31 -1 -2
32 0 -2
33 1 -2
64 2 -2
211 -2 -3
242 -1 -3
243 0 -3
244 1 -3
275 2 -3
486 3 -3
781 -3 -4
992 -2 -4
1023 -1 -4
1024 0 -4
1025 1 -4
1056 2 -4
1267 3 -4
2048 4 -4
2101 -4 -5
2882 -3 -5
3093 -2 -5
3124 -1 -5
3125 0 -5
3126 1 -5
3157 2 -5
3368 3 -5
4149 4 -5
4651 -5 -6
6250 5 -5
6752 -4 -6
7533 -3 -6
7744 -2 -6
7775 -1 -6
7776 0 -6
7777 1 -6
7808 2 -6
8019 3 -6
8800 4 -6
9031 -6 -7
*/


Measured memory_bytes: 21532