akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	
	for(int j = 0; j < n; ++j)
	{
		string numA;
		string numB;
		cin >> numA >> numB;
		
		while(numA.size() != numB.size())
		{
			if(numA.size() < numB.size())
			{
				numA = "0" + numA;
			}
			else
			{
				numB = "0" + numB;
			}
		}
		
		numA = "0" + numA;
		numB = "0" + numB;
		
		for(int i = numA.size() - 1; i >= 0; --i)
		{
			int sum = 0;
			sum = (numA[i] - '0') + (numB[i] - '0');
			
			if(sum >= 10)
			{
				sum -= 10;
				numA[i - 1] += 1;
			}
			
			numA[i] = sum + '0';
		}
		
		if(numA.size() > 81)
		{
			cout << "overflow" << endl;
			continue;
		}
		if(numA.size() == 81 && numA[0] != '0')
		{
			cout << "overflow" << endl;
			continue;
		}
		
		for(int i = 0; i < numA.size(); ++i)
		{
			if(i == 0 && numA[i] == '0') continue;
			cout << numA[i];
		}
		
		cout << endl;
	}
	return 0;
}

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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


const int MOD = 1E9 + 7, N = 1E6 + 1;
ll fact[N];
ll exp(int a, int n) {
        if (n == 0) return 1;
        ll b = exp(a, n / 2);
        (b *= b) %= MOD;
        if (n & 1) (b *= a) %= MOD;
        return b;
}

ll C(int n, int k) {
        return fact[n] * exp(fact[k], MOD - 2) % MOD * exp(fact[n - k], MOD - 2) % MOD;
}

void _main() {
        ll x, y; cin >> x >> y;
        if ((2 * x - y) % 3 || 2 * x - y < 0) {
                cout << 0;
                return;
        }

        int a = (2 * x  - y) / 3;
        int b = a - x + y;
        if (a < 0 || b < 0) {
                cout << 0;
                return;
        }

        fact[0] = 1;
        for (int i = 1; i <= a + b; i++) fact[i] = fact[i - 1] * i % MOD;

        cout << C(a + b, a);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 8868
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int MAX_N=55;
const int MAX_L=35;
ll ans=inf;
int n,len[MAX_N];
ll c[MAX_N],dp[MAX_N][MAX_L][2];
char s[MAX_N][MAX_L];
ll dfs(int id,int pos,int dir)
{
	if(pos>len[id]) return dp[id][pos][dir]=0;
	if(~dp[id][pos][dir]) return dp[id][pos][dir];
	ll &tmp=dp[id][pos][dir];
	tmp=inf;
	bool flag=true;
	if(!dir){ for(int st=pos,ed=len[id];st<ed;st++,ed--)if(s[id][st]!=s[id][ed]){ flag=false; break; } } 	
	else{ for(int st=pos,ed=1;st>ed;st--,ed++)if(s[id][st]!=s[id][ed]){ flag=false; break; } } 
	if(flag) return dp[id][pos][dir]=0;
	repi(i,1,n){
		flag=true;
		int j,k;
		if(!dir){
			for(j=pos,k=len[i];j<=len[id]&&k>=1;j++,k--)if(s[id][j]!=s[i][k]){ flag=false; break; }
			if(flag) tmp=min(tmp,c[i]+((k<1)?dfs(id,j,0):dfs(i,k,1)));
		}
		else{
			for(j=pos,k=1;j>=1&&k<=len[i];j--,k++)if(s[id][j]!=s[i][k]){ flag=false; break; }
			if(flag){
				if(j<1) tmp=min(tmp,c[i]+dfs(i,k,0));
				else tmp=min(tmp,c[i]+dfs(id,j,1));
			}
		}
	}
	return tmp;
}
int main()
{
	si(n); memset(dp,-1,sizeof(dp));
	repi(i,1,n) ss(s[i]+1),sl(c[i]),len[i]=strlen(s[i]+1);
	repi(i,1,n) ans=min(ans,c[i]+dfs(i,1,0));
	printf("%lld\n",(ans==inf)?-1:ans);
	return 0;
}


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

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

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

	swap(&a, &b);
	swap(&a, &c);
	cout << a << " " << b << " " << c;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	my_io();
	int n, k;
	cin >> n >> k;
	if (n % 2 == 1) {
		if (k <= n / 2 + 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		if (k <= n / 2 ) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int a,b;
	cin>>a>>b;
	int c=a*b;
	cout<<c;
	return 0;
}

Measured memory_bytes: 3652
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp = [float("inf") for _ in range(N + 1)]
dp[1] = 0
for i in range(1, N+1):
    for k in range(1, K+1):
        if i + k <= N:
            dp[i+k] = min(dp[i + k], dp[i] + abs(h_list[i-1] - h_list[i-1+k]))

print(dp[N])


Measured memory_bytes: 56928
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W=map(int,input().split())
    for _ in range(H):
        C=input()
        print(C+'\n'+C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
n, k = map(int,input().split())
h = [int(input()) for _ in range(n)]
h.sort()
between = [h[i+1]-h[i] for i in range(n-1)]
answer = 10**9
for i in range(1,n-1):
  between[i] += between[i-1]
between.insert(0,0)

for i in range(n-k+1):
  answer = min(answer, between[i+k-1]-between[i])
  
print(answer)

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

int main(){
  int h;
  int n;
  int s = 0;
  
  cin >> h >> n;
  
  for(int i = 0;i < n;i++){
    int x;
    cin >> x;
    s += x;
  }
    if (s>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
constexpr auto INF = 1000000007;
using namespace std;
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x%y);
}
int lcm(int x, int y) {
    return x / gcd(x, y)*y;
}
int kai(int x) {
    int cnt = 1;
    if (x == 0)return 1;
    cnt = kai(x - 1);
    return x * cnt;
}
int prime(int n) {
    for (int i = 2; i*i <= n; i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}
/*Library End!*/
int n,k,a[100005],ans=INF;
signed main() {
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<=n-k;i++){
        ans=min(ans,a[i+k-1]-a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main()
{
	int m, d;
	while(1){
		int ds = 0;
		cin >> m >> d;
		if(m == 0){
			break;
		}
		for (int i = 1; i < m; ++i)
		{
			if(i == 4 || i == 6 || i == 9 || i == 11){
				ds += 30;
			}else if(i == 2){
				ds += 29;
			}else{
				ds += 31;
			}
		}
		ds += d;
		//cerr << ds << endl;
		ds %= 7;
		switch(ds){
			case 1:
			cout << "Thursday" << endl;
			break;
			case 2:
			cout << "Friday" << endl;
			break;
			case 3:
			cout << "Saturday" << endl;
			break;
			case 4:
			cout << "Sunday" << endl;
			break;
			case 5:
			cout << "Monday" << endl;
			break;
			case 6:
			cout << "Tuesday" << endl;
			break;
			case 0:
			cout << "Wednesday" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

int w,h,n;
int sy,sx,gy,gx;
int y,x,t,prvx,prvy;
string s;
int d[1010][510];
ll dist[500000];
vector<P> g[500000];
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};
const char dir[] = {'U', 'R', 'D', 'L'};

int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  cin >> w >> h >> n;
  cin >> sx >> sy >> gx >> gy;
  memset(d,0,sizeof(d));

  for(int i=0;i<n;i++){
    cin >> x >> y >> t >> s;
    for(int j=0;j<t;j++){
      for(int k=0;k<(int)s.size();k++){
	if(s[k] == 'U'){
	  prvx = x; prvy = y;
	  if(0<=y+dy[0] && y+dy[0]<h)y += dy[0];
	  if(0<=x+dx[0] && x+dx[0]<w)x += dx[0];
	  if(prvx == x && prvy == y)continue;
	  d[2*(y+1)][x]++;
	}else if(s[k] == 'R'){
	  prvx = x; prvy = y;
	  if(0<=y+dy[1] && y+dy[1]<h)y += dy[1];
	  if(0<=x+dx[1] && x+dx[1]<w)x += dx[1];
	  if(prvx == x && prvy == y)continue;
	  d[2*y+1][x]++;
	}else if(s[k] == 'D'){
	  prvx = x; prvy = y;
	  if(0<=y+dy[2] && y+dy[2]<h)y += dy[2];
	  if(0<=x+dx[2] && x+dx[2]<w)x += dx[2];
	  if(prvx == x && prvy == y)continue;
	  d[2*y][x]++;
	}else if(s[k] == 'L'){
	  prvx = x; prvy = y;
	  if(0<=y+dy[3] && y+dy[3]<h)y += dy[3];
	  if(0<=x+dx[3] && x+dx[3]<w)x += dx[3];
	  if(prvx == x && prvy == y)continue;
	  d[2*y+1][x+1]++;
	}
      }
    }
  }
  /*
  for(int i=0;i<2*h+1;i++){
    if(i&1){
      for(int j=0;j<w+1;j++)cout << d[i][j] << " ";
    }else{
      for(int j=0;j<w;j++)cout << d[i][j] << " ";
    }
    cout << endl;
  }
  */
  for(int i=0;i<h+1;i++){
    for(int j=0;j<w;j++){
      int f = i*(w+1)+j, t = i*(w+1)+j+1;
      g[f].push_back(P(d[2*i][j],t));
      g[t].push_back(P(d[2*i][j],f));
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w+1;j++){
      int f = i*(w+1)+j, t = (i+1)*(w+1)+j;
      g[f].push_back(P(d[2*i+1][j],t));
      g[t].push_back(P(d[2*i+1][j],f));
    }
  }

  priority_queue<P,vector<P>,greater<P> > q;
  q.push(P(0,sy*(w+1)+sx));
  for(int i=0;i<(w+1)*(h+1);i++)dist[i] = 1e15;
  dist[sy*(w+1)+sx] = 0;

  while(q.size()){
    P p = q.top(); q.pop();
    int v = p.second;
    ll cost = p.first;

    if(v==gy*(w+1)+gx){
      break;
    }
    if(dist[v] < cost)continue;

    for(int i=0;i<g[v].size();i++){
      int nxt = g[v][i].second;
      ll ncost = cost + g[v][i].first;
      if(dist[nxt] > ncost){
	dist[nxt] = ncost;
	q.push(P(ncost,nxt));
      }
    }
  }
  cout << dist[gy*(w+1)+gx] << endl;
}

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

int main(){
  int n,flour,min;
  min = 10000;
  cin >> n >> flour;
  int a[10000];
  
  
  for(int i = 0;i < n;i++){
	cin >> a[i];
	flour -= a[i];
    if(min > a[i]) min = a[i];
  }
  
  cout << n+(flour/min) << endl;
  
 return 0; 
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  int n,m,i,s,c,flag=0;cin>>n>>m;
  vector<int> A(n,-1);
  fo(i,0,m)
  {
      cin>>s>>c;
      if(A[s-1]==c||A[s-1]==-1)A[s-1]=c;
      else flag=1;
      
  }
  if(n>1&&A[0]==0)flag=1;
  else
  {
      fo(i,0,n)
      {
        if(A[i]==-1)
        {
            if(i==0&&n>1)A[i]=1;
            else A[i]=0;
        }
      }
  }
  if(flag)cout<<"-1";
  else
  for(auto  a : A)cout<<a;
  cout<<"\n";

  
  
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
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 main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll mins = 1LL<<60;
    chmin(mins, a*b);
    chmin(mins, a*c);
    chmin(mins, c*b);
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
    else cout << mins << endl;
}

Measured memory_bytes: 256
N,K,S = map(int,input().split())
A = [0 for _ in range(N)]
if S>2:
    for i in range(N):
        if i<N-K:
            A[i] = S-1
        else:
            A[i] = S
else:
    for i in range(N):
        if i<N-K:
            A[i] = S+1
        else:
            A[i] = S
print(*A)

Measured memory_bytes: 46880
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
using ll = long long;

/*
int main(){
    ll N;
    ll cost = 0;
    ll h[20000];
    cin >> N;
    for(int i=0; i<=N; i++){
        cin >> h[i];
    }
    for(int i=0; i != N; i++){
        if(abs(h[i]-h[i+1])>=abs(h[i]-h[i+2])){
            // h[i] = h[i+2];
            cost = cost + abs(h[i]-h[i+1]);
        }else{
            // h[i] = h[i+1];
            cost = cost + abs(h[i]-h[i+2]);
            i = i+1;
        }
    }
    cout << cost << endl;
    return 0 ;
}
*/

int main(){
    long long int h,n,i;
    vector<long long int>v;
    long long int u[200000];

    cin >> n;

    //hの値をvに入れる
    for(i=0; i<n; i++){
        cin >> h;
        v.push_back(h);
    }

    //コストの初期化
    for(i=0; i<n; i++){
        u[i] = 10000000000;
    }
    u[0]=0;

    //dpの更新
    for(i=0; i<n; i++){
        u[i+1] = min(u[i+1],u[i] + abs(v[i]-v[i+1]));
        u[i+2] = min(u[i+2],u[i] + abs(v[i]-v[i+2]));
    }

    cout<<u[n-1]<<endl;
}

Measured memory_bytes: 1908
S=input()
if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int b = x2 - x1, a = y2 - y1;
	cout << x2 - a << " " << y2 + b << " " << x1 - a << " " << y1 + b << endl;
}

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

int main(void){
  int n;
  cin >> n;
  int a;
  set<int> st;
  int cnt = 0;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a >= 3200){
      cnt++;
    }else{
      st.insert(a / 400);
    }
  }
  cout << max(1,(int)st.size()) << " " << st.size() + cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 998244353;
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int a,b,c,k,ans=0;
	sd(a);sd(b);sd(c);sd(k);
	int x=min(a,k);
	ans+=x;k-=x;
	x=min(b,k);k-=x;
	x=min(c,k);k-=x;
	ans-=x;
	pd(ans);
	return 0;
}

Measured memory_bytes: 3784
#include<stdio.h>
#include<math.h>
int main(){
	double x[100],y[100];
	double A,h,c,X,Y;
	int n,i,j,k,m,M;
	while(scanf("%d",&n),n){
		M=-1;
		for(i=0;i<n;i++)
			scanf("%lf,%lf",x+i,y+i);
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				A=hypot(x[i]-x[j],y[i]-y[j])/2;
				if(A<=1){
					c=atan2(y[i]-y[j],x[i]-x[j]);
					h=sqrt(1-A*A);
					X=x[j]+A*cos(c)-h*sin(c);
					Y=y[j]+A*sin(c)+h*cos(c);
					for(m=0,k=0;k<n;k++){
						if(k!=i&&k!=j)
							if(hypot(X-x[k],Y-y[k])<=1)
								m++;
					}
					if(m>M)
						M=m;
					X=x[j]+A*cos(c)+h*sin(c);
					Y=y[j]+A*sin(c)-h*cos(c);
					for(m=0,k=0;k<n;k++){
						if(k!=i&&k!=j)
							if(hypot(X-x[k],Y-y[k])<=1)
								m++;
					}
					if(m>M)
						M=m;
				}
			}
		}
		printf("%d\n",M+2);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
bool vis[100005];
vector<int> ord;
vector<int> nei[100005],rev[100005];
int dp[100005];
void dfs(int v){
	vis[v]=1;
	for(int i=0;i<nei[v].size();i++){
		int u=nei[v][i];
		if(vis[u]) continue;
		dfs(u);
	}
	ord.push_back(v);
}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		x--,y--;
		nei[x].push_back(y);
		rev[y].push_back(x);
	}
	for(int i=0;i<n;i++){
		if(!vis[i]) dfs(i);
	}
	reverse(ord.begin(),ord.end());
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<rev[ord[i]].size();j++){
			int u=rev[ord[i]][j];
//			cout<<u<<endl;
			dp[ord[i]]=max(dp[ord[i]],dp[u]+1);
		}
//		cout<<ord[i]<<" "<<dp[ord[i]]<<endl;;
		res=max(res,dp[ord[i]]);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 13564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> G(200000);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	rep(i, G[0].size()) {
		int a = G[0][i];
		auto p = find(all(G[a]), n - 1);
		if (p != G[a].end()) {
			puts("POSSIBLE");
			return 0;
		}
	}

	puts("IMPOSSIBLE");

	return 0;
}

Measured memory_bytes: 12016
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 20
#define mod 998244353
#define inf 1000000007
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
		public:
			inline void gc(char & _c) {_c=getchar();}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				_x=0;
				while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
				while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
				_f&&(_x=-_x,_f=0);
				return *this; 
			}
			inline void pc(char _c) {putchar(_c);}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				_T _k;
				if(_x==0) {pc('0'),pc(' ');return *this;}
				if(_x<0) pc('-'),_x=-_x;
				while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
				while(_head>0) pc(_num[_head]),--_head;
				pc(' ');
				return *this; 
			}
			#define endl pc('\n')
		fastio() {_f=0,_head=0,_ch=' ';}
	}io;
}using namespace lib;

int a[maxn][maxn];
int honest[maxn];
signed main()
{
//	freopen("ttin.in","r",stdin);
//	freopen("ttout.out","w",stdout);
//	ios::sync_with_stdio(false);
//	cin.tie(0),cout.tie(0);
	int n,k,x,y,ans=0;
	io-n;
	memset(a,-1,sizeof(a));
	for(rgi i=1;i<=n;++i)
	{
		io-k;
		for(rgi j=1;j<=k;++j)
		{
			io-x-y;
			a[i][x]=y;
		}
	}
//	for(rgi i=1;i<=n;++i)
//	{
//		for(rgi j=1;j<=n;++j)
//			io+a[i][j];
//		io.endl;
//	}
	for(rgl f=0;f<1<<n;++f)
	{
		ll t=f,yes=1;
		for(rgi i=1;i<=n;++i)
			honest[i]=t&1,t>>=1;
		for(rgi i=1;i<=n;++i)
			if(honest[i])
				for(rgi j=1;j<=n;++j)
					if(a[i][j]!=-1&&a[i][j]!=honest[j])
					{
						yes=0;
						break;
					}
		if(yes)ans=max(ans,__builtin_popcount(f));
	}
	io+ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
#define MAX 100005

typedef struct node{
  int p; //親
  int l; //一番左の子
  int r; //右の兄弟
}Node;

Node T[MAX];
int D[MAX];
int n;

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);
  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  c = T[u].l;
  while(c != NIL){
    printf("%d",c);
    if(T[c].r!=NIL) printf(", ");
    c = T[c].r;
  }
  printf("]\n");
}

void rec(int u,int p){
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}


int main(){
  int i,j,k,m,g,l,r;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&m,&k);
    for(j=0;j<k;j++){
      scanf("%d",&g);

      if(j == 0){
        T[m].l = g;
      }else{
        T[l].r = g;
      }
      l = g;
      T[g].p = m;
    }
  }
  for(i=0;i<n;i++) if(T[i].p == NIL) r = i;
  
  rec(r,0);

    for(i=0;i<n;i++) print(i);

    return 0;
}



Measured memory_bytes: 6392
#include <iostream>

using namespace std;

int main(){
    int N,W[100],ans1=0,ans2=0,ans=10000;
    cin >>N;
    for(int i=0;i<N;i++){
        cin >>W[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j<=i){
                ans1=ans1+W[j];
            }else{
                ans2=ans2+W[j];
            }
        }
    if(ans1>ans2){
        ans1=ans1-ans2;
    }else{
        ans1=ans2-ans1;
    }
    ans=min(ans1,ans);
    ans1=0,ans2=0;
    }
    cout <<ans<<endl;
}

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
//constexpr int INF = 1e9;
constexpr ll INF = 1LL << 61;
constexpr int mod = 1e9+7;

ll left_search(ll key, vector<ll>& a){
  int n = a.size();
  int left = -1, right = n;
  while(abs(left-right) > 1){
    int mid = (left+right)/2;
    if(a[mid] <= key){
      left = mid;
    }
    else{
      right = mid;
    }
  }
  return (left==-1 ? -INF : a[left]);
}
ll right_search(ll key, vector<ll>& a){
  int n = a.size();
  int left = -1, right = n;
  while(abs(left-right) > 1){
    int mid =(left+right) /2;
    if(a[mid] >= key){
      right = mid;
    }
    else{
      left = mid;
    }
  }
  return (right == n ? INF : a[right]); 
}
ll calDist(ll a, ll b, ll x){
  if(x <= a && x <= b){
    return abs(max(a, b) - x);
  }
  else if(a <= x && b <= x){
    return abs(x - min(a, b));
  }
  else{
    ll da = abs(x-a), db = abs(x-b);
    return abs(da+db + min(da, db));
  }
}
ll getDist(ll la, ll lb, ll ra, ll rb, ll x){
  ll ans = min(calDist(la, lb, x), calDist(ra, rb, x));
  ans = min(ans, calDist(la, rb, x));
  ans = min(ans, calDist(ra, lb, x));
  return ans;
}
int main(){
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> s(A), t(B);
  REP(i, A){
    cin >> s[i];
  }
  REP(i, B){
    cin >> t[i];
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  while(Q--){
    ll x;
    cin >> x;
    ll la = left_search(x, s), lb = left_search(x, t), ra = right_search(x, s), rb= right_search(x, t);
    ll ans = getDist(la, lb, ra, rb, x);
    cout << ans << endl;        
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

long long comb(long long n,long long k){
    long long ret = 1;
    for(long long i=n;i>n-k;i--){
        long long j = n-i+1;
        ret *= i;
        ret /= j;
    }
    return ret;
}
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    vector<long long>items;
    for(int i=0;i<n;i++){
        long long buf;
        cin >> buf;
        items.push_back(buf);
    }
    sort(items.begin(), items.end());
    reverse(items.begin(), items.end());
    long long maxSum = 0;
    for(int i=0;i<a;i++){
        maxSum += items[i];
    }
    double maxAve = (double)maxSum / (double)a;
    printf("%.16f\n", maxAve);

    long long cnt=0;
    for(int i=a; i<=b;i++){
        long long sumbuf=0;
        for(int j=0;j<i;j++){
            sumbuf += items[j];
        }
        if(maxSum * i > sumbuf * a){
            break;
        }
        long long mini = items[i-1];
        long long need=0;
        long long choosable=0;
        for(int k=0;k<n;k++){
            if(items[k] == mini){
                choosable++;
                if(k < i){
                    need++;
                }
            }else if(items[k] < mini){
                break;
            }
        }
            cnt+=comb(choosable, need);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
input1 = input()
input2 = input()
input3 = input()

input1a = input1.split(" ")
input2a = input2.split(" ")

s = input1a[0]
t = input1a[1]
a = input2a[0]
b = input2a[1]

if input3 == s:
    a = int(a) - 1
else:
    b = int(b) - 1

print(str(a) +" "+str(b))

Measured memory_bytes: 3064
while True:
    a, op, b = input().split()
    if op == '+':
        print(int(a)+int(b))
    elif op == '-':
        print(int(a)-int(b))
    elif op == '/':
        print(int(a)//int(b))
    elif op == '*':
        print(int(a)*int(b))
    else:
        break


Measured memory_bytes: 5596
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val a = input.nextLong()
    val b = input.nextLong()
    
    var ab = 0L
    for (i in 1..b) {
      ab *= 10
      ab += a
    }
    
    var ba = 0L
    for (i in 1..a) {
      ba *= 10
      ba += b
    }
    
    println(Math.max(ab, ba))
    
  }
}

Measured memory_bytes: 36348
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.14159265359
#define all(v) v.begin(),v.end()
#define vil vector<long int>
#define vi vector<int> 
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define INF 1000000007 
#define MOD 998244353
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define sec second
#define fir first
#define acc(v) accumulate(v.begin(),v.end(),0)
bool mysort(const pair<int,int> &a,  
               const pair<int,int> &b){
                   if(a.first==b.first){
                       return a.sec<b.sec;
                   }
                   return a.first<b.first;
    
}
 
ll power(ll a, ll b){
	ll res=1;
	while(b--){
		res*=a;
	}
	return res;
}
void solve(){
int n;
cin>>n;
fill(ll,a,n);
ll dp[n][n];
for(int l=n-1;l>=0;l--){
    for(int r=l;r<n;r++){
        if(l==r){
            dp[l][r]=a[l];
        }
        else{
        dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
    }
}
}
cout<<dp[0][n-1]<<endl;

}

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
ll T;
T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int  ans = 0;
    if (S[0] == T[0]) ans++;
    if (S[1] == T[1]) ans++;
    if (S[2] == T[2]) ans++;
    cout << ans << endl;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
#define MOD 1000000007
ll dp[10001][100][2];

int main(){
    std::ios::sync_with_stdio(false);

    string s;
    int d;
    cin >> s >> d;

    dp[0][0][0] = 1;
    for(int i=0;i<s.length();++i)
    {
      for(int j=0;j<d;++j)
      {
        for(int k=0;k<10;++k)
        {
          int digit = s[i] - '0';
          if(k < digit)
          {
            dp[i+1][(j+k) % d][1] += (dp[i][j][0] + dp[i][j][1]);
            dp[i+1][(j+k) % d][1] %= MOD;
          }else if(k == digit)
          {
            dp[i+1][(j+k) % d][0] += dp[i][j][0];
            dp[i+1][(j+k) % d][1] += dp[i][j][1];
            dp[i+1][(j+k) % d][0] %= MOD;
            dp[i+1][(j+k) % d][1] %= MOD;
          }else
          {
            dp[i+1][(j+k) % d][1] += dp[i][j][1];
          }
        }
      }
    }
    cout << (dp[s.length()][0][0] + dp[s.length()][0][1] - 1) % MOD << endl;
}

Measured memory_bytes: 15872
import sys

patterns = ( 'S', 'H', 'C', 'D' )
n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in patterns }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	cards[ pattern ][ int( num )-1 ] = True

for pattern in patterns:
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

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

int main() {
  int n, m; cin >> n >> m;
  map<int,set<int>> ms;
  string ans = "IMPOSSIBLE";
  rep(i,m) {
    int a, b; cin >> a >> b;
    ms[a].insert(b);
    ms[b].insert(a);
  }
  for (auto a : ms[1]) {
    if (ms[a].count(n)) {
      ans = "POSSIBLE";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 40996
#include<bits/stdc++.h>
using namespace std;
int n,a[26];
long long ans;
char s[20];
map <string,long long> mapp;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%s",s);
		string str="";
		for(int j=0;j<=25;j++) a[j]=0;
		for(int j=0;j<10;j++) a[int(s[j]-'a')]++;
		for(int j=0;j<=25;j++)
			str=str+char(a[j]-49);
		mapp[str]++;
	}
	map <string,long long> :: iterator it;
	for(it=mapp.begin();it!=mapp.end();it++)
		ans+=(it->second)*((it->second)-1)/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 12800
import java.util.*;

public class Main{

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

        String S = sc.nextLine();
        String T = sc.nextLine();

        int count = 0;
        for(int i = 0; i < S.length(); i++){
            if(S.charAt(i) != T.charAt(i)){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main(){
    int n; cin >> n;
    vector<pair<int,int> > student(n);
    rep(i,n){
        cin >> student[i].first;
        student[i].second = i+1;
    }
    sort(student.begin(),student.end());
    rep(i,n){
        printf("%d ",student[i].second);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1536
using System;
using System.Linq;

namespace _176_c
{
    internal class Step
    {
        private static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine() ?? throw new InvalidOperationException());
            var a = Console.ReadLine()?.Split(" ").Select(int.Parse).ToArray();
            if (a == null) return;

            var head = 0;
            long sum = 0;
            for (var i = 0; i < n; i++)
            {
                if (a[i] > head)
                {
                    head = a[i];
                }
                else
                {
                    sum += head - a[i];
                }
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 46996
#include <iostream>
#include <string>
#include <cstdio>
#include <string.h>

using namespace std;

int main() {
  string s;
  char buf[200];
  char tmp[200] = {0};
  int m;
  size_t h;

  for (;;) {
    cin >> s;
    if (s == "-") {
      break;
    }
    strncpy(buf, s.c_str(), s.size());
    buf[s.size()] = '\0';

    cin >> m;
    const size_t len = s.size();
    for (int i = 0; i < m; ++i) {
      cin >> h;

      memmove(tmp, buf, h);
      memmove(buf, buf + h, len - h);
      memmove(buf + len - h, tmp, h);
    }

    printf("%s\n", buf);
  }

  return 0;
}

Measured memory_bytes: 1232
n,m=map(int,input().split())
p=[]
s=[]
t=[]
crc=0
wrg=0
for i in range(m):
    li=input().split()
    p.append(int(li[0]))
    s.append(li[1])
    
for j in range(n):
    t.append(0)
for k in range(m):
    if s[k]=="AC":
        if t[p[k]-1]>=0:
            crc+=1
            wrg+=t[p[k]-1]
            t[p[k]-1]=-1
    else:
        if t[p[k]-1]>=0:
            t[p[k]-1]+=1
print(str(crc)+" "+str(wrg))

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> gram(N);
    for (int i = 0; i < N; i++) {
        cin >> gram.at(i);
    }
    int count = 0;

    sort(gram.begin(), gram.end());
    for (int i = 0; i < N; i++) {
        X -= gram.at(i);
    }
    while (X >= gram.at(0)) {
        X -= gram.at(0);
        count++;
    }
    cout << count + N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
#define BIT(S,i) ((S&(1ll<<i))>0)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

signed main(){
	int N,M;
	cin>>N>>M;
	string s;
	cin>>s;
	vector<int>cntA(N),cntB(N);
	vector<vector<int>>g(N);
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
		if(a==b){
			if(s[a]=='A')cntA[a]++;
			else cntB[a]++;
		}else{
			if(s[a]=='A')cntA[b]++;
			else cntB[b]++;
			if(s[b]=='A')cntA[a]++;
			else cntB[a]++;
		}
	}
	queue<int>que;
	vector<int>used(N);
	REP(i,N){
		if(cntA[i]==0||cntB[i]==0){
			que.push(i);
			used[i]=1;
		}
	}
	while(!que.empty()){
		int now = que.front();
		que.pop();
		for(auto e:g[now]){
			if(s[now]=='A'){
				if(used[e]==0&&--cntA[e]==0){
					que.push(e);
					used[e]=1;
				}
			}else{
				if(used[e]==0&&--cntB[e]==0){
					que.push(e);
					used[e]=1;
				}
			}
		}
	}
	REP(i,N){
		if(used[i]==0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 12932
s = input()

def cal_sum(s, is_plus):
    s_idx = 0
    result = 0
    for p_idx, p in enumerate(is_plus):
        if p == '1':
            result += int(s[s_idx:p_idx+1])
            s_idx = p_idx + 1
    result += int(s[s_idx:])
    return result

res = 0
for i in range(2**(len(s)-1)):
    is_plus ='{i:0={width}b}'.format(i=i, width=len(s)-1) 
    res += cal_sum(s, is_plus)
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long double ll;
typedef pair <ll,ll> P;

int n;
P p[10];

int main(){

  cin >> n;
  rep(i,0,n) cin >> p[i].first >> p[i].second;

  ll ans=0;
  cout << setprecision(20) << fixed;

  ll m = 1;
  rep(i,1,n+1) m *= (ll)i;

  sort(p,p+n);

  do{
    ll k=0;
    rep(i,0,n-1){
      k += sqrt((p[i].first-p[i+1].first)*(p[i].first-p[i+1].first)
          +  (p[i].second-p[i+1].second)*(p[i].second-p[i+1].second));
    }
    ans += k/m;

  }while(next_permutation(p,p+n));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

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

S.append(0)

C = Counter(S).most_common()

Ans = 0
for k,v in C:
    if v >= 2:
        Ans += v*(v-1)//2

print(Ans)


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

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n;
        cin>>n;
        vi h(n);
        rep0(n) cin>>h[i];
        int ans=1,ma=h[0];
        rep(1,n){
            if(h[i]>=ma)
            {
                ma=h[i];
                ans++;
            }
        }
        cout<<ans;
     }
    signed main()
    {   
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#上流からスコアが流れてくるイメージ
from sys import stdin
from collections import deque
input = stdin.readline


def bfs():
  d.append(0)
  trace[0] = 1
 
  while d:
    now = d.pop()
    for next in g[now]:
      if trace[next] == 0:
        trace[next] = 1
        score[next] += score[now]
        d.append(next)


n,q = map(int,input().split())
g = [[] for i in range(n)]

trace = [0]*n#頂点の個数
score = [0]*n

for i in range(n-1):#各々の頂点から行ける頂点のリスト
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  g[a].append(b)
  g[b].append(a)

for i in range(q):
  p,x = map(int,input().split())
  p -= 1
  score[p] += x

d = deque([])

bfs()
      
print(*score)

Measured memory_bytes: 56080
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)













int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    if(x == 1){
        ans += 300000;
    }
    else if(x == 2){
        ans += 200000;
    }
    else if(x == 3){
        ans += 100000;
    }
    
    if(y == 1){
        ans += 300000;
    }
    else if(y == 2){
        ans += 200000;
    }
    else if(y == 3){
        ans += 100000;
    }
    
    if(x == 1 && y == 1){
        ans += 400000;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long long A,B;
long long h[100010];

bool OK(long long key){
	long long cnt=0;
	for(int i=0;i<n;i++){
		long long r=h[i]-key*B;
		if(r>0){
			cnt+=r/(A-B);
			if(r%(A-B)>0)cnt++;
		}
	}
	if(cnt<=key)return true;
	return false;
}

int main(){
	cin>>n>>A>>B;
	for(int i=0;i<n;i++)cin>>h[i];
	int right=2000000010,left=0,mid,ans=2000000010;
	while(left<right){
		mid=(left+right)/2;
		if(OK(mid)){
			right=mid;
			ans=min(ans,mid);
		}
		else {
			left=mid+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};

main {
  while (true) {
    int h, w, c;
    cin >> h >> w >> c;
    if (h == 0 && w == 0 && c == 0) break;
    c--;
    auto v = vectors(h, w, 0LL);
    cin >> v;
    rep(i, h) rep(j, w) v[i][j]--;
    function<void(int, int, int, int)> dfs2 = [&](int i, int j, int a, int b) {
      v[i][j] = b;
      rep(k, 4) {
        int ni = i + di[k], nj = j + dj[k];
        if (ni < 0 || nj < 0 || ni >= h || nj >= w || v[ni][nj] != a) continue;
        dfs2(ni, nj, a, b);
      }
    };
    function<int(int)> dfs = [&](int n) {
      if (n == 0) {
        if (v[0][0] != c) dfs2(0, 0, v[0][0], c);
        int maxi = 0;
        rep(i, h) rep(j, w) {
          if (v[i][j] != c) continue;
          dfs2(i, j, c, -1);
          int cnt = 0;
          rep(k, h) rep(l, w) cnt += v[k][l] == -1;

          cmax(maxi, cnt);
          dfs2(i, j, -1, c);
        }
        return maxi;
      }
      auto tmp = v;
      int maxi = 0;
      rep(i, 6) {
        if (v[0][0] == i) continue;
        dfs2(0, 0, v[0][0], i);
        cmax(maxi, dfs(n - 1));
        v = tmp;
      }
      return maxi;
    };
    cout << dfs(4) << endl;
  }
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define LL long long
//#define rep(i,n) for (int i=0;i<(n);i++)
#define rep(i,x,n) for (int i=x;i<(n);i++)
using namespace std;
int main(){
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	rep(i,1,10){
		rep(j,1,10){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3192
fun main() {
    val (a, b) = readLongs()
    val gcd = gcd(a, b)

    val primeFactors = primeFactors(gcd)
    println(primeFactors.size + 1)
}

fun factorise(nn: Long): List<Long> {
    val factors = mutableListOf<Long>()
    var x = 2L
    var n = nn
    while (x * x <= n) {
        while (n % x == 0L) {
            factors.add(x)
            n /= x
        }
        x++
    }
    if (n > 1) factors.add(n)
    return factors
}

fun primeFactors(n: Long): Map<Long, Int> {
    val factors = factorise(n)
    val occurrences = mutableMapOf<Long, Int>()
    factors.forEach { factor -> occurrences[factor] = occurrences[factor]?.plus(1) ?: 1 }
    return occurrences
}

fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a
    return gcd(b, a % b)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36548
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",strtoupper(fgets(STDIN))));
	}
}

/*		START		*/
$a=getq(1);
echo $a[0][0].$a[1][0].$a[2][0]."\n";
?>

Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;
typedef long long llong;
int main() {
  int n;
  cin >> n;
  vector<pair<llong, llong>> task(n);
  for (int i = 0; i < n; i++) {
    cin >> task[i].second >> task[i].first;
  }
  sort(task.begin(), task.end());
  llong time = 0;
  bool isfinished = true;
  for(int i = 0; i < n; i++){
    if(time + task[i].second <= task[i].first){
      time += task[i].second;
    }
    else{
      isfinished = false;
    }
  }
  if(isfinished){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3328