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

void solve(long long N, long long K, long long R, long long S, long long P, std::string T) {
    long long ans = 0;
    map<char, long long> scoreMap;
    vector<bool> drawVector;
    scoreMap['r'] = P;
    scoreMap['s'] = R;
    scoreMap['p'] = S;
    for (long long i = 1; i <= N; i++) {
        if ((i - 1) < K) {
            ans += scoreMap[T[i - 1]];
            drawVector.push_back(false);
        } else {
            if (T[i - 1] == T[i - 1 - K] && drawVector[i - 1 - K] == false) {
                drawVector.push_back(true);
            } else {
                ans += scoreMap[T[i - 1]];
                drawVector.push_back(false);
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    long long R;
    scanf("%lld", &R);
    long long S;
    scanf("%lld", &S);
    long long P;
    scanf("%lld", &P);
    std::string T;
    std::cin >> T;
    solve(N, K, R, S, P, T);
    return 0;
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

Int dfs(Int a,Int b,Int c,Int d,Int k){
  if(c==10) return 0;
  Int res=0;
  Int x=a%10,y=b%10+d;
  if(x<y){
    chmax(res,dfs(a/10,b/10,c+1,1,k)*10+(x+10-y));
    if(k>0) chmax(res,dfs(a/10,b/10,c+1,0,k-1)*10+(x+10-y));
  }else{
    chmax(res,dfs(a/10,b/10,c+1,0,k)*10+(x-y));
  }
  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int a,b,k;
  cin>>a>>b>>k;
  cout<<dfs(a,b,0,0,k)<<endl;
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vs s(n);
  int res = 0, ab = 0, a = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    for (int j = 0; j + 1 < s[i].size(); ++j) {
      if (s[i][j] == 'A' && s[i][j + 1] == 'B') ++res;
    }
    if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') ++ab;
    else if (s[i][0] == 'B') ++b;
    else if (s[i][s[i].size() - 1] == 'A') ++a;
  }
  res += max(0, ab - 1);
  if (ab && a) {
    ++res;
    --a;
  }
  if (ab && b) {
    ++res;
    --b;
  }
  res += min(a, b);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

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

  for (char s : S)
    cout << (s+N > 'Z' ? (char)(s+N-26) : (char)(s+N));
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e12;

int n, k;

int h[100001];
long long memo[100001];

int main () {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 1; i < n; i++)
		memo[i] = INF;	
	memo[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int prv = 1; prv <= k; prv++) {
			if ((i - prv) >= 0)
				memo[i] = min(memo[i], abs(h[i] - h[i - prv]) + memo[i - prv]);
		}
	}
	cout << memo[n - 1] << "\n";
	return 0;
}


Measured memory_bytes: 1408
sa = list(input())
sb = list(input())
sc = list(input())

turn = 'a'

while 1:
    if turn == 'a':
        if len(sa) == 0:
            print("A")
            break
        else:
            turn = sa.pop(0)
    elif turn == 'b':
        if len(sb) == 0:
            print("B")
            break
        else:
            turn = sb.pop(0)
    else:
        if len(sc) == 0:
            print("C")
            break
        else:
            turn = sc.pop(0)


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x/GCD(x,y)*y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{

int A,B,K;
cin>>A>>B>>K;

int G=GCD(A,B);

int j=0;

for(int i=G;i>0;--i){
if(G%i==0){++j;}
if(j==K){cout<<i<<endl;
break;}
}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

const double eps=1e-10;
double add(double a,double b){
    if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
    return a+b;
}

typedef pair<double,double> P;
P operator+(const P& x,const P& y){
    return {add(x.first,y.first),add(x.second,y.second)};
}

P operator-(const P& x,const P& y){
    return {add(x.first,-y.first),add(x.second,-y.second)};

}

P operator*(const P& x,const double& y){
    return {x.first*y,x.second*y};
}
double dot(P x,P y){
    return add(x.first*y.first,x.second*y.second);


}

double det(P x,P y){
    return add(x.first*y.second,-x.second*y.first);
}

bool onseg(P p1,P p2,P q){
    return det(p1-q,p2-q)==0 &&dot(p1-q,p2-q)<=0; 
}

P intersection(P p1,P p2,P q1,P q2){
    return p1+(p2-p1)*(det(q2-q1,q1-p1)/det(q2-q1,p2-p1));
}

bool cross(P p1,P p2,P q1,P q2){
    if(det(p1-p2,q1-q2)==0)return onseg(p1,p2,q1)||onseg(p1,p2,q2)||onseg(q1,q2,p1)||onseg(q1,q2,p2);
    P ret=intersection(p1,p2,q1,q2);
    return onseg(p1,p2,ret)&&onseg(q1,q2,ret);
}

double dist(P p1,P p2,P q){
    if(dot(q-p1,p2-p1)<=0)return sqrt(dot(q-p1,q-p1));
    if(dot(q-p2,p1-p2)<=0)return sqrt(dot(q-p2,q-p2));
    P d=p1-p2;
    P ret=q+P{d.second,-d.first};
    P h=intersection(p1, p2, q, ret);
    return sqrt(dot(q-h,q-h));
}
double d(P p,P q){
    return sqrt(dot(p-q,p-q));
}

int main(){
    int n;
    while(cin>>n,n!=0){
        P a[n];
        rep(i,n)cin>>a[i].first>>a[i].second;
        int ans=1;
        rep(i,n)rep(j,n){
            if(i==j)continue;
            if(d(a[i],a[j])>2)continue;
            P v=(a[i]-a[j])*(1.0/d(a[i],a[j]));
            P h=P{v.second,-v.first};
            P c=(a[i]+a[j])*(1.0/2)+h*sqrt(1.0-dot(a[i]-a[j],a[i]-a[j])/4);
            int ret=2;
            rep(k,n){
                if(k==i||k==j)continue;
                if(d(a[k],c)<=1)ret++;
            }
            ans=max(ans,ret);
            c=(a[i]+a[j])*(1.0/2)-h*sqrt(1.0-dot(a[i]-a[j],a[i]-a[j])/4);
            ret=2;
            rep(k,n){
                if(k==i||k==j)continue;
                if(d(a[k],c)<=1)ret++;
            }
            ans=max(ans,ret);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ITER(it,v) for(auto it=v.begin();it!=v.end();++it)
#define IN(v) if (scanf("%d", &v)<1);
#define OUT(v) printf("%d\n", v)

int main() {
  int N, M;
  IN(N); IN(M);

  vvi s(M, vi());
  int p[M];
  REP(i, M) {
    int k; IN(k);
    REP(j, k) {
      int _s; IN(_s);
      s[i].push_back(_s-1);
    }
  }
  REP(i, M)
    IN(p[i]);

  int ans = 0;
  REP(bit, 1 << N) {
    bool flag = true;
    REP(j, M) {
      int count = 0;
      ITER(it, s[j]) {
        if ((bit >> *it)&1 == 1)
          ++count;
      }
      if (count % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag)
      ++ans;
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]
a = [int(i)//2 for i in read().split()]

#2で割れる回数
def num_of_2(x):
    c = 0
    while x%2 == 0:
        c  += 1
        x //= 2
    return c

#最小公倍数
from fractions import gcd
def lcm(x,y):
    return x//(gcd(x,y))*y

#2で割れる回数が違ったらアウト
a0 = num_of_2(a[0])
if any([num_of_2(i) != a0 for i in a]):
    print(0)
else:
    #最小公倍数が c のとき、c,3c,5c,... が条件をみたす
    c = 1
    for i in a:
        c = lcm(c,i)
        if c > m: break #mを超えたらもう無意味
    print((m//c+1)//2)

Measured memory_bytes: 14100
#include <stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
int main(){
    int n,m,x,c[12]={},a[12][12]={},y,z[12],b,d=2e9;
    scanf("%d%d%d",&n,&m,&x);
    rep(i,n){
    scanf("%d",&c[i]);
        rep(j,m){
            scanf("%d",&a[i][j]);
        }
    }
    rep(i,2){rep(j,2){rep(k,2){rep(l,2){rep(o,2){rep(p,2){rep(q,2){rep(r,2){rep(s,2){rep(t,2){rep(u,2){rep(v,2){
        y=i*c[0]+j*c[1]+k*c[2]+l*c[3]+o*c[4]+p*c[5]+q*c[6]+r*c[7]+s*c[8]+t*c[9]+u*c[10]+v*c[11];
        for(b=0;b<m;b++){
            z[b]=i*a[0][b]+j*a[1][b]+k*a[2][b]+l*a[3][b]+o*a[4][b]+p*a[5][b]+q*a[6][b]+r*a[7][b]+s*a[8][b]+t*a[9][b]+u*a[10][b]+v*a[11][b];
            if(z[b]<x)break;
        }
        if(b==m&&y<d)d = y;
    }}}}}}}}}}}}
    if(d==(int)2e9)puts("-1");
    else printf("%d",d);
    return 0;
}

Measured memory_bytes: 1712
h, w = map(int, input().split())
table = []
for _ in range(h):
    line = input()
    if line.count(".") != w:
        table.append(line)
table = [list(x) for x in zip(*table)]
ans = []
for t in range(len(table)):
    if table[t].count(".") != len(table[t]):
        ans.append(table[t])
ans = [list(x) for x in zip(*ans)]
for a in ans:
    print("".join(a))



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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        vllin(w,n);
        ll a=0;
        FOR(i,0,n-1){
                a+=w[i];
        }
        ll t=1000000;
        ll k=0;
        FOR(i,0,n-1){
                k+=w[i];
                t=min(t,abs(2*k-a));
        }
        sal(t);
        
}


Measured memory_bytes: 256
h,w,d = map(int,input().split())
n2c = {i:None for i in range(1, h*w+1)}
D = [0] * (h * w + 1)
for i in range(h):
    i += 1
    for j,v in enumerate(input().split()):
        j = j + 1
        v = int(v)
        n2c[v] = (i,j)

for i in range(d+1, h*w+1):
    D[i] = D[i - d] + abs(n2c[i][0] - n2c[i-d][0]) + abs(n2c[i][1] - n2c[i-d][1])

def c(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)

q = int(input())
for i in range(q):
    l,r = map(int, input().split())
    print(D[r] - D[l])

Measured memory_bytes: 62948
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
 
int main() {
    string s;
    cin >> s;
 
    int l = s.length();
 
    vector<int> hub;
    queue<int> boundary;
    boundary.push(-1);
    for(int i=0; i<l-1; i++) {
        if(s.at(i)=='R' && s.at(i+1)=='L')
            hub.push_back(i);
        else if(s.at(i)=='L' && s.at(i+1)=='R')
            boundary.push(i);
    }
    boundary.push(l-1);
 
    vector<int> cell(l, 1);
    int hub_1, hub_2;
    int head_1, head_2;
    head_1 = boundary.front() + 1;
    boundary.pop();
    head_2 = boundary.front() + 1;
    boundary.pop();

    hub_1 = 0;
    hub_2 = hub[0];
 
    for(int i=0; i<hub.size()-1; i++) {
 
        hub_1 = hub[i];
        hub_2 = hub[i+1];
 
        for(int j=head_1; j<head_2; j++) {
            // cout << "i: " << i << " j: " << j << " hub_1: " << hub_1 << " hub_2: " << hub_2 << " head_1:" << head_1 << " head_2: " << head_2 << endl;
            if(j<hub_1 || j>hub_1+1) {
                if(j<hub_1 && (hub_1 - j)%2==1)
                    cell[hub_1+1]++;
                else if(j<hub_1 && (hub_1-j)%2==0)
                    cell[hub_1]++;
                else if(j>hub_1+1 &&(j-hub_1-1)%2==1)
                    cell[hub_1]++;
                else
                    cell[hub_1+1]++;
                cell[j]--;
            }
        }
        head_1 = head_2;
        // if(boundary.size()>0) {
            head_2 = boundary.front() + 1;
            boundary.pop();
        // }
    }
 
    hub_1 = hub_2;
    for(int j=head_1; j<l; j++) {
        // cout << "i: " << -1 << " j: " << j << " hub_1: " << hub_1 << " hub_2: " << hub_2 << " head_1:" << head_1 << "head_2: " << head_2 << endl;
        if(j<hub_1 || j>hub_1+1) {
                if(j<hub_1 && (hub_1 - j)%2==1)
                    cell[hub_1+1]++;
                else if(j<hub_1 && (hub_1-j)%2==0)
                    cell[hub_1]++;
                else if(j>hub_1+1 &&(j-hub_1-1)%2==1)
                    cell[hub_1]++;
                else
                    cell[hub_1+1]++;
                cell[j]--;
            }
    }
 
    for(auto x: cell) cout << x << " ";
    cout << endl;
 
    return 0;
}

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



int main(){
    int a, b, c, d;
    vector<long long int> ans;

    cin >> a >> b >> c >> d;
/*
    long long int x = (long long int)a * (long long int)c;

    cout << a << endl;
    cout << x << endl;

    return 0;
*/
    
    long long int x, max;
    max = LONG_MIN;
    x = (long long int)a * (long long int)c;
    if( x > max ){
        max = x;
    }
    ans.push_back(x);

    x = (long long int)a * (long long int)d;
    if( x > max ){
        max = x;
    }    
    ans.push_back(x);

    x = (long long int)b * (long long int)c;
    if( x > max ){
        max = x;
    }
    ans.push_back(x);

    x = (long long int)b * (long long int)d;
    if( x > max ){
        max = x;
    }
    ans.push_back(x);


    //sort(ans.begin(), ans.end(), greater<int>());

    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3604
if __name__ == '__main__':
	K = int(input())
	dls = [0] * (K+1)
	d = 7 % K
	dls[d] = 1
	c = 1
	if K % 2 == 0:
		c = -1
		d = 0
	while(d != 0):
		d = (d*10 + 7)%K
		if dls[d] == 1:
			c = -1
			break
		else:
			dls[d] = 1
			c += 1
	print(c)

Measured memory_bytes: 71100
#include <iostream>

constexpr int MaxN = 100000;
int exist[MaxN];

int main() {
	int n, ans = 1;

	std::cin >> n;

	exist[0] = 1;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;

		++exist[a];

		if (exist[a] == 3) {
			std::cout << 0 << std::endl;
			return 0;
		}
		else if (a != 0 && exist[a] == 2) {
			ans <<= 1;
			ans %= 1000000007;
		}
	}

	std::cout << ans << std::endl;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	REP(i, SIZE(S))
	{
		if (S[i] == '+')
			ans++;
		else
			ans--;
	}
	cout << ans << endl;
	return 0;
}


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

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


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  int ans=0;
  for(int i=0;i<N;i++){
    if((i+1)%2&&a[i]%2)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3612
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld n; cin >> n;
	vector<lld> arr(n);
	_input(arr);
	lld ans = 0ll;
	for4 (i, 0ll, n, 1ll) {
		lld temp; cin >> temp;
		if (temp < arr[i]) ans += (arr[i] - temp);
	}

	cout << ans;

	cout << "\n";

	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int count = 0;
		for( int i=0; i<40; i++ ){
			if( N>=K ){
				count++;
				N = N/K;
			}else{
				break;
			}
		}
		System.out.println(count+1);
	}
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;

ll a[maxN];
double b[maxN];
double c[maxN];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=k+1;i<=n;i++)
	{
		if(a[i] > a[i-k])
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
  int a;
  scanf("%d", &a);
  std::string s;
  std::cin >> s;

  if (a < 3200)
  {
    std::cout << "red";
  }
  else
  {
    std::cout << s;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**5 + 5)  # 再帰回数の上限！！

n = int(input())
A = [-1] + [int(input()) - 1 for i in range(n-1)]

M = [[] for i in range(n)]
for i in range(1, n):
    M[A[i]].append(i)

# 0-indexedの場合
V = [0] * n

# print(M)

def des(x):
    D = []
    V[x] = 1
    for i in M[x]:
        if V[i] == 0:
            V[i] = 1
            D.append(des(i))
    D.sort(reverse=True)
    # print(x,D)
    for i in range(len(D)):
        D[i] += i+1
    if len(D) == 0:
        ans = 0
    else:
        ans = max(D)
    return ans

print(des(0))

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int k,x;
int main() {
    cin>>k>>x;
    int range = (k*2)-1;

    int i;
    for(i = 0; i<range-1; i++){
        cout << (x-(k-1)) + i << " ";
    }
    cout << (x-(k-1)) + i << endl;
    return 0;
}

Measured memory_bytes: 256
import cmath
def match(st,tt):
    for i,j in zip(st,tt):
        #print ("#",st,tt,i,j)
        if i!="?" and i!=j:
            return False
    return True

s=input()
t=input()
lens=len(s)
lent=len(t)
list=[]
for i in range(lens-lent+1):
    st=s[i:i+lent]
    #print(i,st)
    if match(st,t)==True:
        ss=s[:i]+t+s[i+lent:]
        #print(ss,ss.replace("?","a"))
        list.append(ss.replace("?","a"))
list.sort()
if list!=[]:
    print(list[0])
else:
    print("UNRESTORABLE")




Measured memory_bytes: 3064
def main():

    s = str(input())
    t = str(input())

    dp = [[0]*3100 for _ in range(3100)]

    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

    i = len(s)
    j = len(t)
    ans = []
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans.append(s[i-1])
            i -= 1
            j -= 1
    ans.reverse()
    print(''.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 149640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


n, m = map(int, readline().split())
if is_prime(m):
    if n == 1:
        print(m)
    else:
        print(1)
    exit()
for i in range(m // n, 0, -1):
    if m % i == 0:
        print(i)
        exit()


Measured memory_bytes: 40044
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int N,K;
    cin >> N >> K;
    vint p(N);
    vector<double> q(N+1);
    rep(i,N)cin >> p[i];
    q[0] = 0.0;
    rep(i,N) q[i+1] =q[i] + (double)(p[i]+1)/2;
    
    double ans =0;
    rep(i,q.size()-K){
        ans = max(q[i+K]-q[i],ans);
    }
    COUT(5) << ans;
    return 0;
}

Measured memory_bytes: 2560
/*input
2 4
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=1e5+5;
ll f(ll a){
	if(a<=0) return 0;
	if(a%4==0){
		return a;
	}
	else if(a%4==1){
		return 1;
	}
	else if(a%4==2){
		return a+1;
	}
	else{
		return 0;
	}
}
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<(f(b)^f(a-1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const int INF=1<<30,MOD=1000000007;
const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    vi c(9);
    int n;
    cin>>n;
    REP(i,n){
        int a;
        cin>>a;
        c[min(8,a/400)]++;
    }
    int ans=0;
    REP(i,8)ans+=!!c[i];
    cout<<ans+(ans?0:!!c[8])<<endl;
    cout<<ans+c[8]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	cout<<(a+b+c>=22?"bust":"win")<<"\n";
	return 0;
}

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  int min = 100000, max = 0;
  for (int ii=0; ii<N; ++ii) {
    int a;
    std::cin >> a;
    A[ii] = a;
    min = std::min(a,min);
    max = std::max(a,max);
  }

  std::vector<int> C(max-min+3,0);
  for (int& a : A)
    C[a+1-min]++;
  
  int max_count=0, X=0;
  for(int ii=1; ii < C.size()-1; ++ii) {
    int count = C[ii-1] + C[ii] + C[ii+1];
    if (count > max_count) {
      max_count = count;
      X = ii;
    }
  }
  std::cout << max_count << std::endl; 
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        set<int> s;
        REP(i, n) {
                int a;
                cin >> a;

                if (s.find(a) != s.end()) {
                        cout << "NO" << endl;
                        return 0;
                } else {
                        s.insert(a);
                }
        }

        cout << "YES" << endl;

        return 0;
}


Measured memory_bytes: 9600
import sys

data = sys.stdin
data_list = data.readlines()
data_1 = data_list[0].strip("\n").split(" ")
data_2 = data_list[1].strip("\n").split(" ")
i = 0

if data_1[1] == "0":
  print(data_1[0])
else:
  while True:
    if int(data_1[0]) - i >= 0:
      ans = int(data_1[0]) - i
      if str(ans) not in data_2:
        print(ans)
        break
    ans = int(data_1[0]) + i
    if str(ans) not in data_2:
      print(ans)
      break
    i += 1

Measured memory_bytes: 9212
#pragma GCC optimize ("O3")
#pragma GCC target("avx512f")
#pragma GCC optimize("unroll-loops")
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#pragma endregion
#pragma endregion
int x[200000];
int y[200000];
lint ans;

int main(void) {
  ios::sync_with_stdio(false);
std::cin.tie(nullptr);
	lint n; cin >> n;
	ans = 0;
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int j = 0; j < n; j++) cin >> y[j];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			ans ^= x[i] + y[j];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5176
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"("<<a.x<<" , "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[";for(const auto &i:a)out<<i<<" , ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{";for(const auto &i:a)out<<i<<" , ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"<";for(const auto &i:a)out<<i<<" , ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<'[';for(size_t i=0;i<N;++i)out<<a[i]<<" , ";out <<"]"<<endl;return out;}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	string s;
	cin>>s;
	int n=s.size()+1,i;
	vector<int> a(n,0);
	for(i=1;i<n-1;i++){
		if(s[i-1]=='<')
			a[i]=max(a[i],a[i-1]+1);
	}
	for(i=n-2;i>0;i--){
		if(s[i]=='>')
			a[i]=max(a[i],a[i+1]+1);
	}
	if(s[0]=='>')
		a[0]=a[1]+1;
	if(s[n-2]=='<')
		a[n-1]=a[n-2]+1;
	// vector<char> ch(n,'.');
	// for(i=1;i<n;i++)
	// 	ch[i]=s[i-1];
	// cout<<ch<<"  "<<a;
	int sm=0;
	for(i=0;i<n;i++)
		sm+=a[i];
	cout<<sm;
	return 0;
}


Measured memory_bytes: 4764
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

}

use input::*;
fn main() {
    let (n, t, a): (usize, usize, isize);
    input!(n);
    input!(t, a);

    let v = input_vector::<usize>();
    let mut ans = (999999.0, 0);

    let mut i = 1;
    for z in v {
        let temp = t as f64 - z as f64 * 0.006;
        if (temp - a as f64).abs() < ans.0 {
            ans = ((temp - a as f64).abs(), i);
        }
        i += 1;
    }
    p(ans.1);
}


Measured memory_bytes: 4352
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

S = [0 for k in range(N)]
for k in range(N):
    S[k] = S[k-1] + A[k]

S = [0] + S
S = Counter(S)

ans = 0
for k in S:
    ans += (S[k]*(S[k]-1))//2

print(ans)


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int r;
  int ans;
  cin >> r;
  cout << (3*r*r) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
using std::string;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

//Z-algorithm
//sの1-N文字目とsの共通接頭辞の長さを格納したベクトルを返す
//res[0]は自明にs.length()になる
vector<int> z_algorithm(const string &s) {
    auto n = s.length();
    vector<int> res(n);
    //
    for (int i = 1, j = 0; i < n; i++) {
        if (i + res[i-j] < j + res[j]) {
            //
            res[i] = res[i-j];
        } else {
            int k = std::max(0, res[j] - i + j);
            while (i+k < n && s[k] == s[i+k]) {
                ++k;
            }
            res[i] = k;
            j = i;
        }
    }
    res[0] = (int) n;
    return res;
}

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

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    int N;
    std::cin >> N;
    string S;
    std::cin >> S;
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        auto res = z_algorithm(S.substr(i, N-i));
        for (int j = 0; j < N-i; j++) {
            int len = res[j];
            len = std::min(len, j);
            ans = std::max(ans, len);
        }
        //std::cout << i << ",  " << ans << std::endl;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() 
{
	double w;
	while (std::cin >> w) {
		if (w <= 48.00)
            		cout << "light fly" << endl;
		 else if (w > 48.00 && w <= 51.00)
			cout << "fly" << endl;
		else if (w > 51.00 && w <= 54.00)
            		cout << "bantam" << endl;
		else if (w > 54.00 && w <= 57.00)
            		cout << "feather" << endl;
		else if (w > 57.00 && w <= 60.00)
            		cout << "light" << endl;
		else if (w > 60.00 && w <= 64.00)
            		cout << "light welter" << endl;
		else if (w > 64.00 && w <= 69.00)
            		cout << "welter" << endl;
		else if (w > 69.00 && w <= 75.00)
            		cout << "light middle" << endl;
		else if (w > 75.00 && w <= 81.00)
            		cout << "middle" << endl;
		else if (w > 81.00 && w <= 91.00)
            		cout << "light heavy" << endl;
		else if (w > 91.00)
            		cout << "heavy" << endl;
    }
	return 0;
}



Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        long a = long.Parse(Console.ReadLine());
        long[] s = Console.ReadLine().Split().Select(long.Parse).ToArray();
        bool ren = false;
        long renko = 0;
        long zoka = 0;
        long ans = 0;
        for (long i = 0; i < a - 1; i++)
        {
            if (s[i] == s[i + 1])
            {
                ren = true; renko++;
            }
            else if (s[i + 1] > s[i] && (zoka == 1 || zoka == 0)) { zoka = 1; ren = true; renko++; }
            else if (s[i + 1] < s[i] && (zoka == -1 || zoka == 0)) { zoka = -1; ren = true; renko++; }
            else { ren = false; zoka = 0; }
            if (!ren) { ans++; }
         //   if (i == a - 2 ) { ans++; }
        }
        Console.WriteLine(ans+1);
        Console.ReadLine();
    }
}



Measured memory_bytes: 22880
#include <stdio.h>

void trace(int A[], int N){
	int i;
	for (i = 0; i < N; i++){
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void swap(int *a, int *b){
    int temp;
    temp = *a;

    *a = *b;
    *b = temp;
}

int bubbleSort(int A[], int N){
    int flag, count, j;
    flag = 1;
    count = 0;
    while (flag==1){
        flag = 0;
        for (j = N - 1; 0 < j; j--){
            if (A[j] < A[j-1]) {
                swap(&(A[j]), &(A[j-1]));
                flag = 1;
                count++;
            }

        }
    }
    return count;
}



int main(void){
    int A[100];
    int N, i, count;

    scanf("%d", &N);
    for (i=0; i < N; i++) scanf("%d", &A[i]);

    count = bubbleSort(A, N);

    trace(A,N);
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
set<string> s;
int main(){
	char i[5];
	char o[13];
	int n;
	cin>>n;
	while(n--){
		cin>>i;
		cin>>o;
		string str;
		if(i[0]=='i'){
			s.insert(o);
		}
		else if(i[0]=='f'){
			if(s.count(o)!=0){
				cout<<"yes"<<endl;
			}else{
				cout<<"no"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 28972
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}






Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using vvi = vector<vector<int>>;
using vi = vector<int>;

int main(){
    int H,W;
    cin >> H >> W;
    vvi obstacle(H, vi(W));
    for(int i =0; i < H; i++){
        string s;
        cin >> s;
        for(int j =0; j < W; j++){
            if(s.at(j) =='#') obstacle[i][j] = 1;
            else obstacle[i][j] = 0;
        }
    }
    vvi L(H, vi(W));
    vvi R(H, vi(W));
    vvi U(H, vi(W));
    vvi D(H, vi(W));
    for(int j = 0; j < W; j++){
        for(int i = 1; i < H; i++){
            if(obstacle[i - 1][j]) U[i][j] = 0;
            else U[i][j] = U[i - 1][j] + 1;
            if(obstacle[H - i][j]) D[H -1- i][j] = 0;
            else D[H - 1 - i][j] = D[H-i][j] + 1;
        }
    }
    for(int i =0; i < H; i++){
        for(int j = 1; j < W; j++){
            if(obstacle[i][j - 1]) L[i][j] = 0;
            else L[i][j] = L[i][j - 1] + 1;
            if(obstacle[i][W -j]) R[i][W -1-j] = 0;
            else R[i][W -1 -j] = R[i][W- j] + 1;
        }
    }
    int ans = 0;
    for(int i =0; i < H; i++){
        for(int j =0; j < W; j++){
            if(obstacle[i][j] == 1) continue;
            int temp = U[i][j] + D[i][j] + L[i][j] + R[i][j] + 1;
            if(temp > ans) ans = temp;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100000000010

ll S, N;

ll Func(ll b, ll n) {
    if(n < b) { return n; }
    else { return Func(b, n/b) + (n % b); }
}

int main()
{
    cin >> N >> S;
#if 0
    for(ll i = 2; i <= N; ++i) {
        printf("b: %lld s: %lld\n", i, Func(i, N));
    }
#else
    ll maxVal = (N % 2 == 0) ? (N / 2) : (N / 2 + 1);
    if(S == N) {
        printf("%lld\n", S + 1);
        return 0;
    }
    else if(S > maxVal) {
        printf("-1\n");
        return 0;
    }
    ll ans = maxVal + (maxVal - S);
    if(N % 2 == 0) { ans++; }

    DBG("first ans: %lld\n", ans);
    ll b = N / 2;
    ll inc = 2;
    while(b > 1) {
        ll cand = Func(b, N);
        if(cand == S) { ans = min(ans, b); }
        if(inc < b) {
            ll prev_b = b;
            DBG("prev_b: %lld\n", prev_b);
            b -= ((b - cand) / (inc + 1));
            while(Func(b, N) > Func(b+1, N)) { b--; }
            DBG("b: %lld\n", b);
            if(S >= cand && (S - cand) % inc == 0) {
                ll x = (S - cand) / inc;
                DBG("x: %lld\n", x);
                if(prev_b - b > x) {
                    DBG("ans: %lld\n", prev_b - x);
                    ans = min(ans, prev_b - x);
                }
            }
            inc++;
        } else {
            b--;
        }
    }

    printf("%lld\n", ans);
#endif

    return 0;
}


Measured memory_bytes: 256