akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
int mes[200010];
int main()
{
    int n;
    scanf("%d",&n);
    ff(i,1,n)
    scanf("%d",&mes[i]);
    if(n%2)
    {
        for(int i=n;i>=1;i-=2)
        printf("%d ",mes[i]);
        for(int i=2;i<=n-1;i+=2)
        printf("%d ",mes[i]);
    }
    else
    {
        for(int i=n;i>=2;i-=2)
        printf("%d ",mes[i]);
        for(int i=1;i<=n-1;i+=2)
        printf("%d ",mes[i]);
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size() - 1;
  for (int bit = 0; bit < (1 << n); bit++) {
    string ans;
    ans += s.at(0);
    int k = s.at(0) - '0';
    for (int i = 2; i >= 0; i--) {
      if (bit & (1 << i)) {
        k += s.at(4 - i - 1) - '0';
        ans += "+";
        ans += s.at(4 - i - 1);
      } else {
        k -= s.at(4 - i - 1) - '0';
        ans += "-";
        ans += s.at(4 - i - 1);
      }
    }
    if (k == 7) {
      cout << ans << "=7" << endl;
      return 0;
    } else {
      ans.clear();
    }
  }

}


Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  for(i<-1 to 4) {
    val s = readLine.split(" ").map(_.toInt)
    s(0) match {
      case 1 => println(6000*s(1))
      case 2 => println(4000*s(1))
      case 3 => println(3000*s(1))
      case 4 => println(2000*s(1))
      case _ => throw new Exception("unexpected error")
    }
  }
}

Measured memory_bytes: 43856
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b,c;
   cin >> a >> b >> c;

   if(c>=a && c<=b) cout << "Yes" << endl;
   else cout << "No" << endl;


   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

int n;
ll s,w,q;
ll a[100001];
ll sum[100005];

int main(void){
	while(1){
		scanf("%d%lld%lld%lld",&n,&s,&w,&q);
		if(n==0 && s==0 && w==0 && q==0)break;
		ll g=s;
		for(int i=0;i<n;i++){
			a[i]=(g/7)%10;
			if(g%2==0){
				g=(g/2);
			}else{
				g=(g/2)^w;
			}
		}
		ll ans=0;
		if(q==2 || q==5){
			int cnt=0;
			for(int i=0;i<n;i++){
				if(a[i]%q==0){
					if(a[i]!=0)cnt++;
					ans+=(ll)cnt;
				}else{
					cnt++;
				}
			}
		}else{
			sum[n]=0;
			ll k=1;
			for(int i=n-1;i>=0;i--){
				sum[i]=(ll)(sum[i+1]+a[i]*k)%q;
				k=(k*10LL)%q;
			}
			map<ll,ll> mp;
			for(int i=0;i<n;i++){
				if(a[i])mp[sum[i]]++;
				ans+=mp[sum[i+1]];
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

typedef long long ll;

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

    cin >> n;

    ll arr[n];
    unordered_map<ll, ll> m;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        m[arr[i]] ++;
    }
    ll sum = 0;
    for (auto p : m) {
        ll x = p.second;
        sum += x * (x - 1) / 2;
    }

    for (int i = 0; i < n; ++i) {
        ll k = arr[i];
        cout << sum - m[k] + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 10440
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,pos,x[100010],id,g[100010],u;
long long s[100010];
long long ans;
int read()
{
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return x;
}
void work(int l,int r)
{
	if(u<=l) {for(int i=r;i>=l;--i) g[id--]=i; return;}
	if(u>=r+1) {for(int i=l;i<=r;++i) g[id--]=i; return;}
	if(s[l]>=s[r]) {
		g[id--]=r;
		s[l]+=s[r];
		work(l,r-1);
	}
	else{
		g[id--]=l; s[r]+=s[l];
		work(l+1,r);
	}
}
signed main()
{
	n=read(); pos=read();
	for(int i=1;i<=n;++i) x[i]=read(),s[i]=read();
	id=n; u=lower_bound(x+1,x+n+1,pos)-x;
	work(1,n);
	for(int i=1;i<=n;++i) ans+=abs(x[g[i]]-pos),pos=x[g[i]];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const long long INF=1LL<<60;
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; }
using namespace std;
int main(){
int n;
  cin>>n;
long long h[1000010];
  long long dp[1000010];
  rep(i,n) cin>>h[i];
  rep(i,1000010) dp[i] =INF;
  dp[0]=0;
  for(int i=1;i<n;i++){
  	chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]) );
    if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 12204
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int n, k, a, b, m[] = {3, 1, 2};
  cin >> n >> k;
  n++;
  for(int i = 0;i < k; i++){
    cin >> a >> b;
    if(a >= n / 2) a = n - a;
    if(b >= n / 2) b = n - b;
    cout << m[min(a, b) % 3] << endl;
  }
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																					   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(false); cin.tie(NULL);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL n;
	cin >> n;
	LL suma = 0;
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0){
			continue;
		}		
		else if(i % 5 == 0){
			continue;
		}
		else if(i % 5 == 0 && i % 3 == 0){
			continue;
		}
		else suma += i;
	}

	cout << suma << endl;



	

	return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
	int X,b,p,ans=-1,i,tmp;
	scanf("%d",&X);
	
	for(b=1; b<=X; b++){
		for(p=2; p<11; p++){
			tmp=b;
			for(i=0; i<p; i++){
				tmp*=b;
				if(tmp>X)
					break;
				//printf("%d\n",tmp);
				if(tmp<=X && tmp>=ans)
					ans=tmp;
			}
		}
	}
	printf("%d\n",ans);
			
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] w = new long[n];
		long sum1=0;
		long sum2=0;
		long ans1=0;
		long ans2=0;
        for(int i = 0; i < n; i++){
			w[i] = sc.nextLong();
		}
		for(int i = 0; i<n; i++){
			sum1+=w[i];
			sum2+=w[i];
			if(sum1>0 && i%2==1){
				ans1+=Math.abs(sum1)+1;
				sum1=-1;
			}else if(sum1<0 && i%2==0){
				ans1+=Math.abs(sum1)+1;
				sum1=1;
			}else if(sum1==0){
				ans1+=1;
				if(i%2==1){
					sum1=-1;
				}else{
					sum1=1;
				}
			}
			if(sum2>0 && i%2==0){
				ans2+=Math.abs(sum2)+1;
				sum2=-1;
			}else if(sum2<0 && i%2==1){
				ans2+=Math.abs(sum2)+1;
				sum2=1;
			}else if(sum2==0){
				ans2+=1;
				if(i%2==1){
					sum2=1;
				}else{
					sum2=-1;
				}
			}
		}
		System.out.println(Math.min(ans1,ans2));
	}
}

Measured memory_bytes: 60932
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ---------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> S(N),T(M);
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  for(int i=0; i<M; i++){
    cin >> T[i];
  }
  vector<vector<ll>> dp(N+1, vector<ll> (M+1,0));
  vector<vector<ll>> sum(N+1, vector<ll> (M+1,0));
  dp[0][0] = 1;
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      if(S[i] == T[j]){
        dp[i+1][j+1] = sum[i][j] + 1;
        dp[i+1][j+1] %= mod;
      }else{
        dp[i+1][j+1] = 0;
      }
      sum[i+1][j+1] = (sum[i][j+1] + sum[i+1][j] + dp[i+1][j+1] + mod - sum[i][j])%mod;
    }
  }
  ll ans = 0;
  for(int i=0; i<=N; i++){
    for(int j=0; j<=M; j++){
      ans += dp[i][j];
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
	int N;
	cin>>N;
    vector <long>a(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
    }
	
	long x=0,y=0;
	long sum;
	long min;
	for(int i=1 ; i<N ; i++){
		y+=a[i];
	}
	x+=a[0];
	min=x-y;
	if(min<0)min*=-1;
	for(int i=1 ; i<N-1 ; i++){
		x+=a[i];
		y-=a[i];
		sum=x-y;
		if(sum<0)sum*=-1;
		if(min>sum)min=sum;
	}
	cout<<min<<"\n";
	
	
	return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_left


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n+1)

    def sum(self, i):  # [0, i)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):  # i > 0
        assert i > 0
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]

d = [0] * (n+1)
d2 = {0}
for i in range(n):
    d[i+1] = d[i] + a[i] - k
    d2.add(d[i+1])

d2 = sorted(d2)

bit = Bit(len(d2))

ans = 0
for i in range(n+1):
    d2_i = bisect_left(d2, d[i])
    ans += bit.sum(d2_i+1)
    bit.add(d2_i+1, 1)

print(ans)


Measured memory_bytes: 81112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define ll long long

int main()
{
    int n;
    string s;
    cin >> n >> s;
    ll r = 0, g = 0, b = 0;
    for (char c : s) {
        if(c == 'R')
            r++;
        else if (c =='G')
            g++;
        else
            b++;        
    }
    ll all = r * g * b;
    ll sub = 0;
    rep(i,n) {
        repk(j,i,n){
            if (s[i] != s[j]) {
                int k = 2 * j - i;
                if (k < n && s[k] != s[i] && s[k] != s[j])
                    sub++;
            }
        }
    }
    ll ans = all - sub;
    cout << ans << endl;
}

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

int main(){
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  rep(i,n) cin >> t[i];
  sort(t.begin(), t.end());
  int prev = 0;
  int cnt = 0;
  int res = 1;
  rep(i,n) {
    if (t[i] <= t[prev] + k && cnt < c) {
      cnt++;
      //if (cnt == c) cnt = 0, prev = i+1;
    } else {
      cnt = 1;
      prev = i;
      res++;
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;

ll h, w, a, b, mod = 1000000007;
ll factorial[100000 * 2+1], ans = 0;

ll pow2(int a, int p) {
	if (p == 1)return a;
	else if (p == 0)return 1;

	ll res = pow2(a, p / 2);
	res = (res*res)%mod;
	if (p % 2 == 1)res = (res*a)%mod;

	return res;
}

void init() {
	factorial[0] = 1;
	for (int i = 1; i <= h + w; i++) {
		factorial[i] = (factorial[i - 1] * i)%mod;
	}
}

ll ncr(int n, int r) {
	return (factorial[n] * pow2(factorial[r], mod - 2)%mod)*pow2(factorial[n - r], mod - 2)%mod;
}


int main() {
	cin >> h >> w >> a >> b;
	init();

	for (int i = 0; i < h - a; i++) {
		ans = (ans + (ncr(i + b - 1, i)*ncr((h - i) + (w - b) - 2, h - i - 1)%mod))%mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;









void solve(){

    int x;
    cin >> x;
    cout << (x^1);
       

}




int main() {
    int T;
    //if (0==0) cin >> T;  
    //else T = 1;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




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

int check(char a, char b, char c) {
  if (a == b && b == c) {
    return 0;
  }

  if (a == b && b != c) {
    return 1;
  }

  if (a == c && c != b) {
    return 1;
  }

  if (b == c && c != a) {
    return 1;
  }

  if (a != b && b != c) {
    return 2;
  }

  return 0;
}

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += check(a[i], b[i], c[i]);
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	string S;
	cin >> S;
	int N = S.size();
	int nokori = N - 1;
	int saigo = N;
	int kaisuu = (N - 2) / 2;
	int base = 2;
	if (S[0] == '0' || S[N - 1] == '1' || S[N - 2] == '0') {
		co(-1);
	}
	else {
		rep1(i, kaisuu) if (S[i] != S[N - i - 2]) {
			co(-1);
			return 0;
		}
		cosp(1);
		co(2);
		nokori--;

		rep(i, kaisuu) {
			if (S[i + 1] == '0') {
				cosp(base);
				co(saigo);
				saigo--;
				nokori--;
			}
			else {
				cosp(base);
				co(base + 1);
				base++;
				nokori--;
			}
		}
		rep1(i, nokori) {
			cosp(base);
			co(base + i);
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 1616
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}

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

using namespace std;

void Main() {
    long long N;
    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return;
    }

    map<int, int> factorized;
    int sqrtN = 1 + (int)sqrt((double)N);
    for (int i = 2; i <= sqrtN; ++i) {
        while (N % i == 0) {
            if (factorized.count(i) == 0) {
                factorized.insert(make_pair(i, 0));
            }
            factorized[i] += 1;
            N /= i;
        }
    }
    if (N != 1) {
        factorized.insert(make_pair(N, 1));
    }

    int ans = 0;
    for (auto element : factorized) {
        //cout << element.first << " " << element.second << endl;
        int e = element.second;
        e -= 1;
        ++ans;
        for (int i = 2; i <= e; ++i) {
            if (e - i < 0) {
                break;
            }
            e -= i;
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define ub  upper_bound
#define lb  lower_bound
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;

const int mod = 998244353;

struct Segtree{
  vll st;
  int len;
  void build(int n){
    len = n;
    st.assign(4*n,0);
  }

  void update(int l,int r,int pos,int i,ll v){
    if(i < l || i > r)
      return;
    if(l == r){
      st[pos] = v;
      return;
    }
    int m = (l+r)/2;
    update(l,m,2*pos+1,i,v);
    update(m+1,r,2*pos+2,i,v);

    st[pos] = st[2*pos+1] + st[2*pos+2];
  }
  void update(int i,ll v){
    update(0,len-1,0,i,v);
  }
  ll get_sum(int l,int r,int pos,int ql,int qr){
    if(ql > r || qr < l)
      return 0;
    if(ql <= l && r <= qr)
      return st[pos];
    
    int m = (l+r)/2;

    return get_sum(l,m,2*pos+1,ql,qr) + get_sum(m+1,r,2*pos+2,ql,qr);
  }
  ll get_sum(int ql,int qr){
    return get_sum(0,len-1,0,ql,qr);
  }
  
};

int main(){
  fastio;

  int n,k;
  cin >> n >> k;

  vpii segs(k);

  for(int i=0;i<k;i++)
    cin >> segs[i].f >> segs[i].s;
  
  Segtree st;
  st.build(n+1);
  vll dp(n+1,0);
  dp[1] = 1;
  st.update(1,1);

  for(int i=2;i<=n;i++){
    for(int j=0;j<k;j++){
      int l = segs[j].f;
      int r = segs[j].s;
      if(i-l < 1)
        continue;
      dp[i] += st.get_sum(max(1,i-r),i-l); 
      dp[i] %= mod;
    }
    st.update(i,dp[i]);
  }

  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 11132
#include <iostream>
#include <queue>

using namespace std;

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

signed main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i,n) {
    int a;
    cin >> a;
    q.push(a);
  }
  
  rep(i,m) {
    int a = q.top(); q.pop();
    q.push(a / 2);
  }
  
  int s = 0;
  while(!q.empty()) s += q.top(), q.pop();
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 4296
#include <stdio.h>
#include <string.h>

int main(void)
{

  char S[10];
 scanf("%s",S);
 if(S[0]=='A'){
 	
 	int n;
 	int flag=0;
 	for(n=2;n<strlen(S)-1;n++){
 		if(S[n]=='C'){
 			if(flag==0){
 			flag=1;
 			}else{
 				flag=0;
 				break;
 			}
 		}
 		
 	}

 	if(flag){
 		int sum=0;
 		for(n=0;n<strlen(S);n++){
 			if(S[n]>=97&&S[n]<=122){
 				sum++;
 			}
 		}
 		
 		if(sum==strlen(S)-2){
 			printf("AC\n");
 		}else{
 			printf("WA\n");
 		}
 		
 	}else{
 		printf("WA\n");
 	}
 	
 }else{
 	printf("WA\n");
 }
  	
  
  
  
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, l, b, a[N];
int main()
{
	int i;
	cin >> n >> l;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	for (b = 1; b < n; b++) if (a[b] + a[b - 1] >= l) break;
	if (b == n) {cout << "Impossible"; return 0;}
	puts("Possible");
	for (i = 1; i < b; i++) printf("%d\n", i);
	for (i = n - 1; i > b; i--) printf("%d\n", i);
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 1152
import collections
import copy

ans = ["a"]
now = ["a"]
N=int(input())
for i in range(1,N):
    ans=[]
    for c in now:
        mojisuu = len(collections.Counter(c).values())
        for j in range(mojisuu+1):
            ans.append(c+chr(j+97))
    now = copy.deepcopy(ans)

for c in ans:
    print(c)

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

int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
vector<string> maze(30);

struct P {
  int y,x;
};

int bfs(int y,int x) {
  int cnt=0;
  vector<vector<int>> d(30,vector<int>(30,-1));
  queue<P> q;
  q.push({y,x});
  d[y][x]=0;
  P now,next;
  while(!q.empty()) {
    now=q.front(); q.pop();
    for(int i=0;i<4;i++) {
      next={now.y+dy[i],now.x+dx[i]};
      if(d[next.y][next.x]==-1&&maze[next.y][next.x]!='#') {
        d[next.y][next.x]=d[now.y][now.x]+1;
        cnt=max(cnt,d[next.y][next.x]);
        q.push(next);
      }
    }
  }
  return cnt;
}


int main() {
  int h,w; cin>>h>>w;
  int ans=0;

  for(int i=0;i<=w+1;i++) {
    maze[0]+='#';
    maze[h+1]+='#';
  }
  for(int i=1;i<=h;i++) {
    string m; cin>>m;
    maze[i]='#'+m+'#';
  }

  for(int i=1;i<=h;i++) {
    for(int j=1;j<=w;j++) {
      if(maze[i][j]=='.') {
        ans=max(ans,bfs(i,j));
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctype.h>
#include <stack>
#include <bitset>
#include <iterator>
using namespace std;
#define ull unsigned long long
#define ll long long
const int maxn=1e5+5;
ll A,B;
ll getnum(ll x,int p){
	if(x<0) return 0;
	ll k=1ll<<p;
	return (x/(k*2))*k+max(0ll,x%(k*2)-k+1);
}
int main(void){
	scanf("%lld%lld",&A,&B);
	ll ans=0;
	for(int i=0;(1ll<<i)<=B;++i)
		ans+=(getnum(B,i)-getnum(A-1,i))%2*(1ll<<i);
	printf("%lld\n",ans);
	return 0;
}
		

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

struct RollingHash {
    int n;
    long long base1, base2, mod1, mod2;
    vector<long long> hash1, hash2, pow1, pow2;
    RollingHash(const string &s) : base1(1009), base2(1007), mod1(998244353), mod2(1000000009) {
        n = s.size();
        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);
        for(int i = 0; i < n; i++) {
            hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
            hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    //[l, r)
    pair<long long, long long> get(int l, int r) {
        long long t1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
        long long t2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
        return {t1, t2};
    }
    // LCP of S[l, ..] and S[r, ..]
    int LCP(int l, int r){
        int len = n - r;
        int low = -1, high = len + 1;
        while(high - low > 1){
            int mid = (low + high) / 2;
            if(get(l, l + mid) == get(r, r + mid)) low = mid;
            else high = mid;
        }
        return low;
    }
};

signed main(){
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    string ss = s;
    string tt = t;
    while(ss.size() < t.size()) ss += s;
    int len = ss.size();
    ss += ss + ss;
    while(tt.size() < ss.size()) tt += t;
    string r = ss + "$" + tt;
    int tidx = ss.size() + 1; 
    RollingHash rh(r);
    int MAX = 0;
    for(int i = 0; i < len; i++){
        int tmp = rh.LCP(i, tidx);
        MAX = max(MAX, tmp);
    }
    if(MAX >= len * 2) cout << -1 << endl;
    else cout << MAX / m << endl;
}

Measured memory_bytes: 205584
function main (s) {
    s=s.split("\n");
	for(var i=0;i<4;i++){
		s[i]=parseInt(s[i]);
	}
	console.log((s[0]<=s[1])?(s[0]*s[2]):(s[1]*s[2]+(s[0]-s[1])*s[3]));
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
deque<char> s1, s2;
char ch='a';
int main()
{
    while(ch!='\n')
    {
        ch=getchar();
        s1.push_back(ch);
    }
    ch='a';
    while(ch!='\n')
    {
        ch=getchar();
        s2.push_back(ch);
    }
    while(!s2.empty())
    {
        printf("%c%c",s1[0],s2[0]);
        s1.pop_front();
        s2.pop_front();
    }
    if(s1.size()) printf("%c",s1[0]);
    return 0;
}


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

#define ARRAYNUM 1000

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

  int f_x=0;
  for(int i=0; i<X.length(); i++) {
    f_x += stoi(X.substr(i,1));
  }

  int Xi = stoi(X);
  cout << (((Xi % f_x) == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int N=1000005;
int len[N],nex[N],last[N],endd[N],tot,dis[N];
bool mark[N];
int n,m;
queue<int>q;
void add(int x,int y,int l)
{
	tot++;
	nex[tot]=last[x];
	last[x]=tot;
	len[tot]=l;
	endd[tot]=y;
}
void spfa(int x)
{
	int i,y,u;
	for(i=1;i<=n;i++)dis[i]=1e9;
	dis[x]=0;mark[x]=1;
	q.push(x);
	while(q.size())
	{
	   u=q.front();
	   q.pop();mark[u]=false;
	   for(i=last[u];i;i=nex[i])
	   {
	   	int y=endd[i];
	   	if(dis[u]+len[i]<dis[y])
	   	{
	   		dis[y]=dis[u]+len[i];
	   		if(!mark[y])
	   		{
	   			q.push(y);
	   			mark[y]=true;
			   }
		   }
	   }
	}
}
int main()
{
	cin>>n>>m;
	int i,j,k,x,y,l;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y,1);
		add(y,x,1);
	}
	spfa(1);
	if(dis[n]>2)puts("IMPOSSIBLE");
	else puts("POSSIBLE");
}

Measured memory_bytes: 11904
#include"bits/stdc++.h"
#define int long long
#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<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int N;cin>>N;
	int n=0;
	while(++n){
		if((n+1)*(n+1)>N) break;
	}
	cout<<n*n<<endl;
}

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

int main(void) {
  int n,sum=0;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for (auto&& vec: v) {
    cin >> vec;
  }
  for (auto&& vec: c) {
    cin >> vec;
  }
  for (int i=0;i<n;i++) {
    if (v[i] > c[i]) {
      sum = sum + (v[i] - c[i]);
    }
  }
  
  cout << sum << endl;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var nmr = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var r = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var dp = new long[nmr[0], nmr[0]];
        for(var i = 0; i < nmr[1]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            dp[input[0] - 1, input[1] - 1] = input[2];
            dp[input[1] - 1, input[0] - 1] = input[2];
        }
        for (var i = 0; i < nmr[0]; i++)
            for (var j = 0; j < nmr[0]; j++)
                if (i != j && dp[i, j] == 0)
                    dp[i, j] = int.MaxValue;
        for (var k = 0; k < nmr[0]; k++)
            for (var i = 0; i < nmr[0]; i++)
                for (var j = 0; j < nmr[0]; j++)
                    dp[i, j] = Min(dp[i, j], dp[i, k] + dp[k, j]);
        var min = long.MaxValue;
        for (var i = 0; i < r.Length; i++)
            min = Min(min, dfs(dp, r, new HashSet<int>(), i));
        WriteLine(min);
    }
    private static long dfs(long[,] fromto, int[] rs, HashSet<int> set, int index)
    {
        set.Add(rs[index]);
        if (set.Count == rs.Length)
        {
            set.Remove(rs[index]);
            return 0;
        }
        var min = long.MaxValue;
        for (var i = 0; i < rs.Length; i++)
        {
            if (!set.Contains(rs[i]))
                min = Min(min, dfs(fromto, rs, set, i) + fromto[rs[index] - 1, rs[i] - 1]);
        }
        set.Remove(rs[index]);
        return min;
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 15708
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, 3)
	}
	dp[0] = []int{0, 0, 0}

	for i := 0; i < n; i++ {
		a, b, c := readInt(), readInt(), readInt()
		dp[i+1][0] = max(dp[i][1], dp[i][2]) + a
		dp[i+1][1] = max(dp[i][2], dp[i][0]) + b
		dp[i+1][2] = max(dp[i][0], dp[i][1]) + c
	}

	fmt.Println(max(dp[n][0], max(dp[n][1], dp[n][2])))
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 998244353
#define MOD 1000000007
signed main()
{
    SPEED;
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            sum+=i;
        }
    }
    cout<<sum;
}

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

int main() {
    int N; cin >> N;
    string s; cin >> s;
    int l = 0;
    int r = N / 2 + 1;
    while(r-l > 1){
        int mid = (l+r)/2;
        bool ok = false;
        vector<string> sub;
        for (int i = 0; i < N-mid+1; i++){
            string now = s.substr(i, mid);
            sub.push_back(now);
        }

        for (int i = 0; i < N-mid; i++){
            for (int j = i+mid; j < N-mid+1; j++){ 
                if(sub[i] == sub[j]){
                    ok = true;
                    break;
                }
            }
            if(ok)break;
        }
        if(ok){
            l = mid;
        } else {
            r = mid;
        }
    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 9616
N = input()
l = len(N)
ans = 0
C = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,int(N)+1):
    s = str(i)
    top = int(s[0])
    bot = int(s[-1])
    C[top][bot] += 1
for i in range(10):
    for j in range(10):
        ans += C[i][j]*C[j][i]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
 
const int mod = 998244353;
int pow2(int x, int p){
    if(p == 0)return 1;
    int sub = pow2(x, p/2);
    int ans = sub*sub;
    assert(ans >= 0 );
    ans %= mod;
    if(p & 1)ans *= x;
    ans %= mod;
    assert(ans >= 0 );
    return ans;
}
int before[(int)2e5] = {0};
int after[(int)2e5] = {0};
int read(int idx, int * tree){
    int sum = 0;
    while (idx > 0){
        sum += tree[idx];
        idx -= (idx & -idx);
    }
    return sum;
}
 
 
int mxx;
void update(int idx, int val, int * tree){
    while (idx <= mxx ){
        tree[idx] += val;
        idx += (idx & -idx);
    }
}
 
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vpii points(n);
    vi ys;
    map<int,int> yMap;
    FOR(i, n){
        cin >> points[i].first >> points[i].second;
        yMap[points[i].second] = 0;
        ys.pb(points[i].second);
    }
    int cnt= 1;
    mxx = yMap.size() + 1;
    for(auto& val: yMap){
        val.second = cnt++;
        update(val.second, 1, after);
    }
    sort(ys.begin(), ys.end());
    sort(points.begin(), points.end());
    int tot = pow2(2, n) - 1;
    int ans = 0;
    assert(cnt == mxx);
    FOR(i, n){
        update(yMap[points[i].second], -1, after);
        int left = pow2(2, i) - 1;
        int right = pow2(2, n - i -1) - 1;
        int down = pow2(2, (lower_bound(ys.begin(), ys.end(), points[i].second) - ys.begin())) - 1;
        int up = pow2(2, (n - 1-  (lower_bound(ys.begin(), ys.end(), points[i].second) - ys.begin()))) - 1;
        int beforeUp = i - read(yMap[points[i].second], before);  
        int beforeDown = i - beforeUp;
 
        int afterUp = (n - i -1) - read(yMap[points[i].second], after);
        int afterDown = (n-i - 1) - afterUp; 
        
        assert(beforeUp >= 0);
        assert(beforeDown >= 0);
        assert(afterUp >= 0);
        assert(afterDown >= 0);
 
        int sub = left + right + down + up - pow2(2, beforeUp) - pow2(2, beforeDown) - pow2(2, afterUp) - pow2(2, afterDown) + 4;
        sub %= mod;
        ans += tot - sub;
        ans %= mod;
        update(yMap[points[i].second], 1, before);
    }
    while(ans < 0)ans += mod;
  	ans %= mod;
    cout <<ans;
 
}

Measured memory_bytes: 20592
#include <bits/stdc++.h>
#define BPhuong "vsteps"
#define maxn 1000009
#define maxm
#define bit(x, i) ((x>>i)&1)
#define fid(i,a,b) for(int i = a; i>=b; i--)
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<int, int>
#define ll long long
#define f first
#define se second
#define pb push_back
using namespace std;
int n, k, h[maxn];
ll f[maxn];
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    srand(time(NULL));
    //freopen(BPhuong".inp", "r", stdin);
    //freopen(BPhuong".out", "w", stdout);
    cin >> n ;
    fi(i, 1, n) cin >> h[i];
}
void xuli(){
    f[1] = 0;
    f[2] = abs(h[2]-h[1]);
    fi(i, 3, n)
        f[i] = min(f[i-1]+abs(h[i]-h[i-1]), f[i-2]+abs(h[i]-h[i-2]));
    cout << f[n];

}
int main(){
    nhap();
    xuli();
}


Measured memory_bytes: 4792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>


using namespace std;

int main() {
	int n,q;
	long long sum = 0;
	vector<int> num(100005);
	cin >> n;

	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		sum += a[i];
		num[a[i]]++;
	}

	cin >> q;
	vector<int> b(q);
	vector<int> c(q);

	for (int i = 0;i < q;i++) {
		cin >> b[i] >> c[i];
	}

	for (int i = 0;i < q;i++) {
		sum -= (long long)b[i] * (long long)num[b[i]];
		sum += (long long)c[i] * (long long)num[b[i]];
		num[c[i]] += num[b[i]];
		num[b[i]] = 0;
		cout << sum << endl;
	}


	return 0;
}

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


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

int n = s.size();
string ans = "No";
if(t.substr(0,n)==s){
    ans = "Yes";
}

cout << ans << endl;



}



Measured memory_bytes: 3632
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long

int main(){
  int k;
  scanf("%d",&k);
  if(k==4 || k==6 || k==9 || k==10 || k==14 ||  k==21 || k==22 || k==25 || k==26){
    printf("2");
    return 0;
  }
  else if(k==8 || k==12 || k==18 || k==20 || k==27){
    printf("5");
    return 0;
  }
  else if(k==16){
    printf("14");
    return 0;
  }
  else if(k==24){
    printf("15");
    return 0;
  }
  else if(k==28 || k==30){
    printf("4");
    return 0;
  }
  else if(k==32){
    printf("51");
    return 0;
  }
  else{
    printf("1");
    return 0;
  }
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    map<ll, int> mp;
    mp[0] = 1;
    ll ans = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        sum += a;
        ans += mp[sum];
        mp[sum]++;
    }

    /*for (auto x : mp) {
        ans += x.second * (x.second - 1) / 2;
    }*/

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 12800
def main():
    a, b = map(str, input().split())

    if a == 'H':
        if b == 'H':
            print('H')
        if b == 'D':
            print('D')
    else:
        if b == 'H':
            print('D')
        if b == 'D':
            print('H')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  int cnt=0;
  for(int i=0;i<str.size()/2;i++){
    if(str[i]!=str[str.size()-i-1]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
num,pat,sum=[],[],[]
i=int(0)
N=int(0)
while 1:
    num=list(map(int,input().split(' ')))
    pat.append(num[0])
    sum.append(num[1])
    if(pat[i]==0 and sum[i]==0):
        break
    i=i+1
    N=N+1
i=0
s=0
while(i<N):
    s=0
    for k in range(1,pat[i]+1):
        for l in range(k+1,pat[i]+1):
            for m in range(l+1,pat[i]+1):
                if(sum[i]==k+l+m):
                    s=s+1
    print(s)
    i=i+1


Measured memory_bytes: 5592
#include<stdio.h>

int main(){
    int n;
    scanf("%d\n",&n);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(int j=n-1; j>0; j--){
        printf("%d ",a[j]);
    }
    printf("%d\n",a[0]);
}



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

int	main()
{
  int	A;
  int	B;
  char	op;
  
  cin >> A >> op >> B;
  if (op == '+')
    cout << (A + B) << endl;
  if (op == '-')
    cout << (A - B) << endl;
  return (0);
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
ll chmax(ll &a, ll b){ return a = (a>b) ? a : b;}
ll chmin(ll &a, ll b){ return a = (a<b) ? a : b;}


////////////////////////////////////////////////////////////////
#define PI 3.14159265359
int main(void) {
	int N;
	cin >> N;
	vector<int> h(N+5, 0);
	for(int i=0; i<N; i++) cin >> h[i];

	vector<ll> dp(N+5, INF);
	dp[0] = 0;// dp[i]: 足場iに行くのにかかる最小コスト

	for(int i=0; i<=N; i++){
		chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
		chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
		//dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));//chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
		//dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]));//chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
	}

	cout << dp[N-1] << endl;


}



Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, C, K; cin >> N >> C >> K;
	vector<int> T(N); rep(i, 0, N) { cin >> T[i]; }
	sort(all(T));
	int t = T[0];
	int ans = 1;
	int c = 1;
	rep(i, 1, N) {
		if (T[i] <= t + K && c < C) {
			c++;
			continue;
		}
		ans++;
		t = T[i];
		c = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
vector <pair<int, long long > >edges[2500];
vector <int> reverse_edges[2500];
long long d[2500];
bool reachable[2500];
//returns false when exists a negative loop
void dfs(int cur){
  reachable[cur] = true;
  for(int i = 0; i < reverse_edges[cur].size(); i++){
    int next = reverse_edges[cur][i];
    if(!reachable[next]){
      dfs(next);
    }
  }
}

bool bellman_ford(int s, int N){
    for(int i = 0; i < N; i++){
        d[i] = LLONG_MAX;
    }

    dfs(N - 1);

    d[s] = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < edges[j].size(); k++){
                int to = edges[j][k].first;
                long long cost = edges[j][k].second;
                if(d[j] != LLONG_MAX && d[to] > d[j] + cost){
                    d[to] = d[j] + cost;
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
      for(int j = 0; j < edges[i].size(); j++){
        int to = edges[i][j].first;
        long long cost = edges[i][j].second;
        if(d[i] != LLONG_MAX && d[to] != LLONG_MAX && d[i] + cost < d[to] && reachable[to]){
          return false;
        }
      }
    }
    return true;
}

int main(){
    int N;
    int M;
    long long P;
    cin >> N >> M >> P;

    for(int i = 0; i < M; i++){
        int A;
        int B;
        int C;
        cin >> A >> B >> C;
        edges[A - 1].push_back(make_pair(B - 1, P - (long long) C));
        reverse_edges[B - 1].push_back(A - 1);
    }

    if(bellman_ford(0, N)){
        cout << max(- d[N - 1], (long long) 0) << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
a,b =map(int,input().split())

str_a = (str(a)*b)
str_b = (str(b)*a)

result = str_a
n = len(str_a)
for i in range(0,n):
  if int(str_a[i]) > int(str_b[i]):
    result = str_b
    break
  elif int(str_a[i]) < int(str_b[i]):
    result = str_a
    break
print(result)



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

#define int long long


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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<pii> a(n);
  rep(i, n) { cin >> a[i].F; a[i].S = i + 1; }
  sort(all(a));
  rep(i, n) cout << a[i].S << " "; cout << endl;
}


Measured memory_bytes: 3976