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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/
/****** define variable start ******/
ll n;
vector<string> s;
/******* define variable end *******/
int solve() {
	cin >> n;
	s.resize(n);
	REP(i,n){
		cin >> s[i];
	}
	sort(s.begin(),s.end());
	string tmp = "";
	ll ans = 0;
	REP(i, n){
		if(s[i] != tmp){
			ans++;
			tmp = s[i];
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

int main() {
  vector<string> days = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string d;
  cin >> d;
  cout << 7 - distance(days.begin(), find(days.begin(), days.end(), d)) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<cassert>
 
struct Meirei{
    std::string mei;
    std::string str;
};

struct Node{
	Node(){
		umu=false;
		a=NULL;
		c=NULL;
		g=NULL;
		t=NULL;
	}
	bool umu;
	Node* a;
	Node* c;
	Node* g;
	Node* t;
};

class Tree
{
public:
	Tree(){
		m_root=new Node();
	}
	void insert(std::string moji);
	bool find(std::string moji);
	
private:
	Node* m_root;
};

void Tree::insert(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL){
				node->a = new Node();
			}
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL){
				node->c =  new Node();
			}
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL){
				node->g = new Node();
			}
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL){
				node->t = new Node();
			}
			node = node->t;
		}else {
			assert(true);
		}
	}
	node->umu=true;
}
//---------------------------------
bool Tree::find(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL){
				return false;
			}
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL){
				return false;
			}
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL){
				return false;
			}
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL){
				return false;
			}
			node = node->t;
		}else {
			assert(true);
		}
	}
	if(node->umu){
		return true;
	}
	return false;
}



//typedef std::vector<MEIREI> VecMeirei;
//typedef std::vector<std::string> WORDS;
//typedef std::vector<bool> ARINASHI;
//void input();
//bool find(WORDS jisho, std::string str);
void output(bool result);
//-------------------------------------------------------------------
int main()
{
    long n;
    std::cin >> n;
    Tree* tree = new Tree();
	for(int i=0; i<n; i++){
		std::string meirei;
	    std::cin >> meirei;
		std::string moji;
		std::cin >> moji;
		if(meirei=="insert"){
		    tree->insert(moji);
	    }else if(meirei=="find"){
	     	output(tree->find(moji));
	    }
	}
	delete tree;
    return 0;
}
//-------------------------------------------------------------------
void output(bool result)
{
    if(result){
        std::cout << "yes" << std::endl;
    }else{
        std::cout << "no" << std::endl;
    }
    return;
}
//-------------------------------------------------------------------

Measured memory_bytes: 19468
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int arr[1010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int N;
    cin >> N;

    for (int i = 0; i < 1010; ++i)
        arr[i] = 1;

    for (int i = 2; i <= N; ++i)
    {
        int t = i;
        for (int j = 2; j <= i; ++j)
        {
            while (t % j == 0)
            {
                arr[j]++;
                t /= j;
            }
        }
    }

    ll ans = 1;
    for (int i = 1; i <= N; ++i)
        ans = (ans * arr[i]) % MOD;

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

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val H = listOfInt()
    var ans = 0
    var cnt = 0
    for (n in 0 until N - 1) {
        if (H[n] >= H[n + 1]) { if (ans < ++cnt) ans = cnt }
        else cnt = 0
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n, a[100000];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}

	int ans = 1, diff = -2;

	for(int i = 1;i < n;i++){
		int d;
		if(a[i] - a[i-1] > 0) d = 1;
		else if(a[i] - a[i-1] < 0) d = -1;
		else d = 0;

		if(diff == -2 or diff == 0){
			diff = d;
			// cout << i << ' ' << diff << endl;
			continue;
		}

		if((diff == -1 and d == 1) or (diff == 1 and d == -1)){
			ans++;
			// cout << i << endl;
			diff = -2;
		}
	}

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

Measured memory_bytes: 640
#include <iostream>

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

    std::string s = "aeiou";

    for (auto e : s) {
        if (e == c) {
            std::cout << "vowel" << std::endl;
            return 0;
        }
    }
    std::cout << "consonant" << std::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 rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		const int D = 86400, E = 10800;
		int cur = 0;
		vector<int> cnt(D, 0);
		rep(i, N) {
			int a; int b;
			scanf("%d%d", &a, &b);
			(cur += a) %= D;
			++ cnt[cur];
			(cur += b) %= D;
		}
		vector<int> sum(D * 2 + 1);
		rep(i, D * 2)
			sum[i + 1] = sum[i] + cnt[i % D];
		int ans = 0;
		rep(i, D)
			amax(ans, sum[i + E + 1] - sum[i]);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1280
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s, t;
    cin >> s >> t;

    sort(ALL(s));
    sort(ALL(t), greater<char>());

    while(true){
        if(s.size()>0 && t.size()>0){
            if(s[0] == t[0]){
                s = s.substr(1);
                t = t.substr(1);
            }
            else{
                if(s[0] < t[0]){
                    p("Yes");
                    return 0;
                }else{
                    p("No");
                    return 0;
                }
            }
        }

        else if(s.size()==0 && t.size() > 0){
            p("Yes");
            return 0;
        }
        else if(s.size()>0 && t.size()==0){
            p("No");
            return 0;
        }
        else{
            p("No");
            return 0;
        }
    }
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll dp[100010][3];
ll a[100010][3];

int main() {
    int N;
    cin >> N;
    rep(i, N) rep(j, 3) cin >> a[i][j];

    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll ans = 0;
    rep(j, 3) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


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

int main(void){
  int A, B;
  cin >> A >> B;
  int sum = 0;
  int temp;
  if(A > B){
    sum += A;
    A--;
  }
  else{
    sum += B;
    B--;
  }
  if(A > B){
    sum += A;
    A--;
  }
  else{
    sum += B;
    B--;
  }
  cout << sum;
 return 0;
  
}

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

int main () {
    float d[6];
    //           p   c   d   q
    // 0 a 1 b 2 c 3 d 4 e 5 f
    while(scanf("%f %f %f %f %f %f", &d[0], &d[1], &d[2], &d[3], &d[4], &d[5]) != EOF ) {
        printf("%.3f %.3f\n",
                floor(((d[2] * d[4] - d[1] * d[5]) / ( d[0] * d[4] - d[1] * d[3])) * 1000 +.5) / 1000,
                floor(((d[5] * d[0] - d[2] * d[3]) / ( d[4] * d[0] - d[3] * d[1])) * 1000 +.5) / 1000
        );
    }

    return 0;
}

Measured memory_bytes: 648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int r = scn.nextInt(), c = scn.nextInt();
        int[][] fld = new int[-~r][-~c];
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                fld[i][j] = scn.nextInt();
                fld[r][j] += fld[i][j];
                fld[i][c] += fld[i][j];
                fld[r][c] += fld[i][j];
            }
        }
        for(int i = 0; i < fld.length; i++) {
            for(int j = 0; j < c; j++) {
                System.out.print(fld[i][j] + " ");
            }
            System.out.println(fld[i][c]);
        }
    }
}

Measured memory_bytes: 39364
import sys
sys.setrecursionlimit(10**8)

N = int(input())
adj = [[] for _ in range(N+1)]
for e in range(1,N):
  a,b = map(int, input().split())
  adj[a].append((b,e))
  adj[b].append((a,e))

#print(adj)

col_num = max([len(ad) for ad in adj])
edge_color = [0]*N
visited = [False]*(N+1)

def dfs(v,c=-1):
  visited[v] = True
  #print(v,e,edge_color)
  #col_lis = [i for i in range(1,col_num+1)]
  #if e >0:
    #col_lis.remove(edge_color[e])
  color = 1
  for w,f in adj[v]:
    if visited[w]==False:
      if c==color: color+=1
      edge_color[f] = color
      dfs(w,color)
      color+=1

dfs(1)

print(col_num)
for i in range(1,N):
  print(edge_color[i])

Measured memory_bytes: 86144
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int H, W, D;
    cin >> H >> W >> D;
    map<int, P> m; 
    REP(i, H)REP(j, W){
        int num;
        cin >> num;
        m[num] = mp(i+1, j+1);
    }
    int Q;
    cin >> Q;
    vector<llint> mpo(H*W+2, 0);
    FOR(dd, 1, D+1)for(int i=0; i*D+dd<=H*W; i++){
        if(i==0) mpo[i*D+dd] = 0;
        else{
            mpo[i*D+dd] = mpo[(i-1)*D+dd]+abs(m[i*D+dd].first-m[(i-1)*D+dd].first)
                                       +abs(m[i*D+dd].second-m[(i-1)*D+dd].second);
        }
        //cout << (i*D+dd) << " " << mpo[i*D+dd] << "\n";
    }
    REP(i, Q){
        int L, R;
        cin >> L >> R;
        cout << mpo[R]-mpo[L] << "\n";
    }
    return 0;
}

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

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

    int n;
    cin >> n;
    map<string, int> m;

    ll ans = 0;
    while (n--) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        ans += m[s]++;
    }

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


Measured memory_bytes: 11264
<?php
# 入力
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));

$cnt_beat = 0;
$tmp = 0;
for ($i = 0; $i < $n; $i++) {
    if ($tmp + $b[$i] > $a[$i]) {
        $cnt_beat += $a[$i];
        $tmp = min($b[$i], $tmp + $b[$i] - $a[$i]);
    } else {
        $cnt_beat += $tmp + $b[$i];
        $tmp = 0;
    }
}
$cnt_beat += min($tmp, $a[$n]);

echo $cnt_beat.PHP_EOL;
?>

Measured memory_bytes: 20976
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	double a, b, x;
	cin >> a >> b >> x;
	x /= a;

	if (x <= a * b / 2) {
		double lb = 0, ub = a;
		rep(_, 1000) {
			double mid = (lb + ub) / 2;

			double c = sqrt(mid * mid + b * b);
			double s = (mid + b + c) / 2;
			double area = sqrt(s * (s - mid) * (s - b) * (s - c));

			if (x <= area) {
				ub = mid;
			}
			else {
				lb = mid;
			}
		}

		double ad = ub;
		double seta = atan2(b, ad);
		double pi = acos(-1.0);
		double arc = seta / pi * 180;
		printf("%.10f\n", arc);
	}
	else {
		x -= a * b / 2;

		double lb = 0, ub = b;
		rep(_, 1000) {
			double mid = (lb + ub) / 2;

			double area = mid * a / 2;

			if (x <= area) {
				ub = mid;
			}
			else {
				lb = mid;
			}
		}

		double bd = ub;
		double seta = atan2(b - bd, a);
		double pi = acos(-1.0);
		double arc = seta / pi * 180;
		printf("%.10f\n", arc);
	}


	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<int> dp(n, 1'000'000'000);
  dp[0] = 0;
  rep(i, n) {
    for (int j = i + 1; j < i + 1 + k; j++) {
      if (j >= n) break;
      dp[j] = min(dp[j], abs(h[j] - h[i]) + dp[i]);
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;

    int64_t result = ao + ai / 2 * 2 + aj / 2 * 2 + al / 2 * 2;
    if (ai > 0 && aj > 0 && al > 0) {
        int64_t tmp = ao + 3 + (ai - 1) / 2 * 2 + (aj - 1) / 2 * 2 + (al - 1) / 2 * 2;
        result = max(result, tmp);
    }

    cout << result << endl;
    return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    for (int i = 0; i < 300; i++) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int i,a=0,b=0;
  for(i=0;i<=2;i++)
  {
    if(s[i]=='A')a++;
    else b++;
  }
  if(a==3 || b==3)cout << "No\n";
  else cout << "Yes\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a & 1) {
			if (~i & 1) ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define sd(x) scanf("%d",&(x))
#define pd(x) printf("%d",(x))
#define slld(x) scanf("%lld",&(x))
#define plld(x) printf("%lld",(x))
#define br printf("\n")
#define pi pair<int,int>
#define pii pair<long long int, long long int>
#define vi vector<int>
#define pb push_back
#define RESET(val) memset(val, 0, sizeof(val))
#define mp(a,b) make_pair(a, b)
#define fi first
#define se second
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define mod 1000000007
#define inf 1000000000
//ll power(ll a,ll b,ll n){ll ans=1;while(b>0){if(b%2==1)ans=(ans*a)%n;a=(a*a)%n;b/=2;}return ans;}
 
int dis[100005], vis[100005];
vector<pi> adj[100005];

void dfs(int u){
    for(pi i: adj[u]){
        if(vis[i.fi] == 1)  continue;
        vis[i.fi] = 1;
        dis[i.fi] = dis[u] + i.se;
        dfs(i.fi);
    }
}
 
signed main(){
//    freopen("input.txt","r",stdin);
    int n,m;
    sd(n); sd(m);
    for(int i = 0; i < m; i++){
        int u,v,d;
        sd(u);sd(v);sd(d);
        adj[u].pb({v,d});
        adj[v].pb({u,-d});
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0){
            vis[i] = 1; dis[i] = 0;
            dfs(i);
        }
    }
    for(int i = 1; i <= n; i++){
        for(pi j : adj[i]){
            if(abs(dis[i] - dis[j.fi]) != abs(j.se))
            {cout<<"No";return 0;}
        }
    }
    cout<<"Yes";
    return 0;
} 

Measured memory_bytes: 11392
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	if( v <= w ) {
		cout << "NO" << endl;
		return 0;
	}
	
	if( abs(b - a) <= abs(v - w) * t ) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>

int main(void)
{

    for(int n = 1; scanf("%d", &n), n != 0;){
        int r = 0;
        for(int i = 2; (n + i / 2) / i - (i / 2) > 0; i++){
            if(i % 2 == 0 && (n - i / 2) % i == 0){
                r++;
            }else if(i % 2 != 0 && n % i == 0){
                r++;
            }
        }
        printf("%d\n", r);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int x[N], y[N], h[N]; rep(i, N) cin >> x[i] >> y[i] >> h[i];

  rep(i, 101) rep(j, 101) {
    int H;
    rep(n, N) if(h[n]!=0) { H = h[n] + abs(i-x[n]) + abs(j-y[n]); break;}
    bool ok = true;
    rep(n, N) if (max((H - abs(i-x[n]) - abs(j-y[n])), 0) != h[n]) ok = false;
    if (ok) { cout << i << " " << j << " " << H; return 0; }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int h, w;
    cin >> h >> w;
    int c[10][10], a[h][w];
    bool state = false;
    repi(i, 10, 0)
    {
        repi(j, 10, 0)
        {
            cin >> c[i][j];
        }
    }

    repi(i, h, 0)
    {
        repi(j, w, 0)
        {
            cin >> a[i][j];
            if (a[i][j] != 1 && a[i][j] != -1)
                state = true;
        }
    }

    if (true)
    {
        repi(i, 10, 0) //経由頂点
        {
            repi(j, 10, 0)//始点
            {
                repi(k, 10, 0)//終点
                {
                    c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
                }
            }
        }
        int ans = 0;
        repi(i, h, 0)
        {
            repi(j, w, 0)
            {
                if (a[i][j] != -1)
                    ans += c[a[i][j]][1];
            }
        }
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,k,val[100005];
vector<int> g[100005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cin>>k;
	memset(val,-1,sizeof(val));
	for(int i=1;i<=k;i++)
	{
		int v,p;
		cin>>v>>p;
		val[v]=p;
		pq.push(make_pair(p,v));
	}
	while(!pq.empty())
	{
		pair<int,int> p=pq.top();
		pq.pop();
		for(int i=0;i<g[p.second].size();i++)
			if(val[g[p.second][i]]==-1)
			{
				val[g[p.second][i]]=val[p.second]+1;
				pq.push(make_pair(val[g[p.second][i]],g[p.second][i]));
			}
	}
	for(int i=1;i<=n;i++)
		for(int j=0;j<g[i].size();j++)
			if(abs(val[g[i][j]]-val[i])!=1)
			{
				cout<<"No"<<endl;
				return 0;
			}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
		cout<<val[i]<<endl;
	return 0;
}


Measured memory_bytes: 7924
// be name khoda
#include<bits/stdc++.h>
 
using namespace std;
 
#define F first
#define S second
//#define mp make_pair 
typedef long long ll;
#define int long long
#pragma GCC optimize("Ofast")
 
const int maxn = 1e5+10;
const int mod = 1e9+7;
const ll inf = 1e18+10;
//const int N = 2e6+10;
 
int n, k;
int a[maxn];

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

    int N = 30000, sum = 0;
    set<int> se, m21, m22, m3, m6;
    for(int i = 1; i <= N; i++)
        if(i%3 == 0 || i%2 == 0)
        {
            if(i%6 == 0) m6.insert(i);
            if(i%3 == 0 && i%2 != 0 && i != 3) m3.insert(i);
            if(i%2 == 0 && i%3 != 0 && i != 2) 
            {
                if(i%3 == 1) m21.insert(i);
                if(i%3 == 2) m22.insert(i);
            }
            se.insert(i);
            sum += i;
        }
    //cout<< sum <<" "<< sum%6 <<"\n";
    cin>> n;

    if(n == 3)
        return cout<< 2 <<" "<< 5 <<" "<< 63, 0;
    if(n == 4)
        return cout<< 2 <<" "<< 5 <<" "<< 63 <<" "<< 20, 0;
    if(n == 5)
        return cout<< 2 <<" "<< 3 <<" "<< 9 <<" "<< 10 <<" "<< 18, 0;

    while(se.size() > n+1 && m3.size() >= 2)
    {
        auto it = m3.begin();
        int X = (*it); it++;
        int Y = (*it); 
        m3.erase(Y); 
        m3.erase(X); 
        se.erase(X);
        se.erase(Y);
    //    if((X+Y) % 6 != 0) 
  //          cout<< X <<" "<< Y <<"\n";
    }
    
    while(se.size() > n+2 && m21.size() >= 3)
    {
        auto it = m21.begin();
        int X = (*it); it++;
        int Y = (*it); it++;
        int Z = (*it); m21.erase(Z);m21.erase(Y); m21.erase(X);
        se.erase(X);
        se.erase(Y);
        se.erase(Z);
   //     if((X+Y+Z) % 6 != 0)    
   //         cout<< X <<" "<< Y <<" "<< Z <<"\n";
    }

    while(se.size() > n+2 && m22.size() >= 3)
    {
        auto it = m22.begin();
        int X = (*it); it++;
        int Y = (*it); it++;
        int Z = (*it); m22.erase(Z); m22.erase(X); m22.erase(Y);
        se.erase(X);
        se.erase(Y);
        se.erase(Z);
   //     if((X+Y+Z) % 6 != 0)    
   //         cout<< X <<" "<< Y <<" "<< Z <<"\n";
    }

    while (se.size() > n && m6.size())
    {
        int X = *m6.begin(); 
        m6.erase(X);
        se.erase(X);
    }
    
    sum = 0;
    for(auto x : se) 
    {
        cout<< x <<" ";
        sum += x;
    }
    //cout<<"\n"<< sum <<" "<< sum % 6;
}


Measured memory_bytes: 2176
<?php
fscanf(STDIN, '%d %d', $n, $m);
$q = new SplPriorityQueue;
for ($i  = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d %d', $a, $b);
    $q->insert([$b, $a], -$a);
}
$num = 0;
$ans = 0;
while ($num < $m) {
    list($dn, $dv) = $q->extract();
    $_num = min($m - $num, $dn);
    $ans += $dv * $_num;
    $num += $_num;
}
echo $ans . PHP_EOL;

Measured memory_bytes: 86520
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n,m;
	cin>>n>>m;//nは色の数 mは人の数
	double a[21][4]={};
	REP(i,n){cin>>a[i][0]>>a[i][1]>>a[i][2];}
	
	double b[21][21]={};
	REP(i,n){REP(j,n){b[i][j]+=(a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2]);}}
	
	int c[21]={};//i番目が選択済みなら1をたてる
	REP(i,m){c[i]=1;}
	sort(c,c+n);
	
	//m<2の時
	if(m<2){cout<<0<<endl;}
	else
	{
	//m=2の時
		double ans(0);
		
		do
		{
			double tmp(0);
			for(int i=0;i<n;i++)
			{
				if(c[i]==1)
				{
					for(int j=i+1;j<n;j++)
					{
						if(c[j]==1)
						{
							tmp+=b[i][j];
						}
					}
				}
			}
			ans=max(ans,tmp);
		}while(next_permutation(c,c+n));
		
		cout <<fixed << setprecision(7) <<  ans <<endl;
	}
	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


class UnionFind {
public:
    VL par; // 各元の親を表す配列
    VL siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(LL sz_): par(sz_), siz(sz_, 1LL) {
        for (LL i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(LL sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (LL i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    LL root(LL x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unionSet(LL x, LL y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool isSame(LL x, LL y) { // 連結判定
        return root(x) == root(y);
    }

    LL size(LL x) { // 素集合のサイズ
        return siz[root(x)];
    }
};




void Main()
{
    LL n,m;cin>>n>>m;
    UnionFind uf = UnionFind(n);
    REP(i,m){
        LL a,b;cin>>a>>b;
        a--;b--;
        uf.unionSet(a,b);
    }

    LL result = 0;
    REP(i,n){
        result = max(result,uf.size(i));
    }
    cout<<result<<endl;

    
	return;
}

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

Measured memory_bytes: 6360
#include <iostream>

using namespace std;

int a[4], b[4];
void solve(){
  int hit = 0, blow = 0;
  for(int i = 0; i < 4 ;i++){
    if(a[i] == b[i])hit++;
    else{
      for(int j = 0;j < 4; j++){
	if(a[i] == b[j])blow++;
      }
    }
  }
  cout << hit << " " << blow << endl;
}
int main(){

  while( cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3] ){
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 1160
n=int(input())
a=list(map(int,input().split()))

cnt=1
s=0
for i in range(1,len(a)):
 if a[i-1]!=a[i]:
  if s==0 and a[i-1]<a[i]:
   s=1
  elif s==0 and a[i-1]>a[i]:
   s=-1
  elif s==-1 and a[i-1]<a[i]:
   s=0
   cnt+=1
  elif s==1 and a[i-1]>a[i]:
   s=0
   cnt+=1
print(cnt)

Measured memory_bytes: 14436
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	int n;
	scanf("%d",&n);
	puts(n/10==9||n%10==9?"Yes":"No");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
pair<int,int> c[114514];
int a[114514],b[114514];
string s[114514],t[114514];
signed main(){
	ic(n) ic(m)
	if(n==m)c("Yes")
	else c("No")
}	


Measured memory_bytes: 2048
from math import gcd


def create_sieve(n):
    sieve = [0] * (n + 1)

    for i in range(2, n + 1):
        if sieve[i] == 0:
            j = i ** 2
            while j <= n:
                sieve[j] = i
                j += i

    return sieve


def fast_factorization(n, sieve):
    from collections import Counter
    arr = Counter()
    while n > 1:
        p = sieve[n]
        if p == 0:
            arr[n] += 1
            break
        else:
            arr[p] += 1
            n //= p
    return arr


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

# setwise
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)


# pairwise
M = 10 ** 6
sieve = create_sieve(M)
done = set()
isPairwise = True
for a in A:
    arr = fast_factorization(a, sieve)
    for p in arr.keys():
        if p in done:
            isPairwise = False
        else:
            done.add(p)

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)


Measured memory_bytes: 204596
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	}
}

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

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=100000000;
  ans=min(ans,a+b);
  ans=min(ans,b+c);
  ans=min(ans,a+c);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int n,sum=0,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		sum=sum+i;
	}	
	cout<<sum<<endl;
	return 0;
}

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

int gcd(int n, int m) {
    return n == 0 ? m
         : m == 0 ? n
         : n < m ? gcd(m, n)
         : gcd(m, n%m);
}

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

    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0, a; i < N; ++i) {
        cin >> a;
        A.push_back(a);
    }

    // The finding number is the maximum GCD of a[] excluding a[i] (0 <= i < N)
    //  = GCD(GCD(a[0..i-1]), GCD(a[i+1..N-1]))

    // a[0] a[1] ... a[i-1] a[i] a[i+1] ... a[N-2] a[N-1]
    // ^^^^^^^^^^^^^^^^^^^^      ^^^^^^^^^^^^^^^^^^^^^^^^
    //       lgcd[i]                     rgcd[i]
    int lgcd[100000 + 1] = {}, rgcd[100000 + 1] = {};
    for (int i = 0; i < N; ++i) {
        lgcd[i + 1] = gcd(lgcd[i], A[i]);
        rgcd[N - i - 1] = gcd(A[N - i], rgcd[N - i]);
    }

    int maxGcd = 1;
    for (int i = 0; i < N; ++i) {
        maxGcd = max(maxGcd, gcd(lgcd[i], rgcd[i]));
    }
    cout << maxGcd << endl;

    return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 13
#define F(a,b,c) for(register int (a)=(b);(a)<=(c);(a)++)
#define PDXD(a,b) (!(a-b))
#define PDBXD(a,b) (!(!(a-b)))
#define CON continue;
#define GO goto endreturn;
using namespace std;
int a[szxb][szxb];
int main()
{
	F(i,1,3){F(j,1,3){scanf("%d",&a[i][j]);}}
	int a1,a2,a3,b1,b2,b3,c1,c2,c3;
	F(i,0,100){a1=(a[1][1]-i);a2=(a[1][2]-i);a3=(a[1][3]-i);F(j,0,100){b1=(a[2][1]-j);b2=(a[2][2]-j);b3=(a[2][3]-j);if((PDBXD(a1,b1))||(PDBXD(a2,b2))||(PDBXD(a3,b3))){CON;}F(k,0,100){c1=(a[3][1]-k);c2=(a[3][2]-k);c3=(a[3][3]-k);if((PDXD(a1,c1))&&(PDXD(a2,c2))&&(PDXD(a3,c3))){printf("Yes");GO;}}}}
	printf("No");
	endreturn:return putchar(10),0;
}

Measured memory_bytes: 256
L, R = ( int(a) for a in input().split() )
mi = 2018
for i in range( L, R ):
    for j in range( i + 1, R + 1 ):
        mi = min( mi, ( i * j ) % 2019 )
        if mi == 0:
            print(0)
            exit()
print( mi )

Measured memory_bytes: 2940
S=str(input())
w=["dream", "dreamer", "erase", "eraser" ]
rw=[]

rs = S[::-1]
for i in w:
    rw.append(i[::-1])


res=False
while len(rs)>0:
    resin = False
    for i in rw:
        if i == rs[0:len(i)]:
            resin=True
            break

    if resin == True:
        rs=rs[len(i):]
        res=True
        continue
    else:
        res=False
        break
        

if res==True:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
N, M = map(int, input().split())
H = list(map(int, input().split()))
connection = [0 for _ in range(N)]
cnt = 1
result = 0
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] < H[B-1]:
        connection[A-1] = -1
    elif H[A-1] > H[B-1]:
        connection[B-1] = -1
    else:
        connection[B-1] = -1
        connection[A-1] = -1

for i in connection:
    if i == 0:
        result += 1

print(result)

Measured memory_bytes: 91764
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n;
  cin >> n;
  vector<ll> a(n), m(n, 0);
  REP(i, n) cin >> a[i];
  
  REP(i, n) m[0] += pow(-1, i) * a[i];
  FOR(i, 1, n) m[i] = 2*a[i-1] - m[i-1];

  REP(i, n) cout << m[i] << " ";
  cout << endl;
  
  return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;
    
    int num = b / a;
    
    cout << min(num, c) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
// #define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 5005;

string s;
int k;
vector<string> v;

void run() {
	v.clear();
	cin >> s >> k;
	int len = s.length();
	for(int i = 1; i <= k; i++) {
		for(int j = 0; j + i - 1 < len; j++) {
			v.push_back(s.substr(j, i));
		}
	}
	sort(all(v));
	unique(all(v));
	cout << v[k - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    run();
    return 0;
}


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

int main() {
	int a;
	string b;
	cin>>a;
	cin>>b;
	for(int i=0;b.size()>i;i++){
		if(b[i]+a>90){
			b[i]=(b[i]-26)+a;
		}
		else b[i]=b[i]+a;
	}
	cout<<b;
	return 0;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
const ll dx[4] = {0, 1, 0, -1};
const ll dy[4] = {1, 0, -1, 0};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, w; cin >> h >> w;
    vector<string> m(h); cin >> m;
    vector<vector<ll>> dist(h, vector<ll>(w, linf));
    queue<P> Q;
    Q.push({0, 0});
    dist[0][0] = 0;
    auto inRange = [&](ll x, ll y) {
        return 0 <= x && x < w && 0 <= y && y < h;
    };
    while ( !Q.empty() ) {
        P p = Q.front(); Q.pop();
        ll x, y; tie(x, y) = p;
        rep(d, 4) {
            ll nx = x + dx[d];
            ll ny = y + dy[d];
            if (inRange(nx, ny) && m[y][x] == '.' && dist[y][x] + 1 < dist[ny][nx]) {
                dist[ny][nx] = dist[y][x] + 1;
                Q.push({nx, ny});
            }
        }
    }
    if (dist[h-1][w-1] == linf) {
        cout << -1 << endl;
    }
    else {
        ll cnt = 0;
        rep(y, h) rep(x, w) if (m[y][x] == '.') ++cnt;
        cout << cnt - dist[h-1][w-1]-1 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<LL,LL> pt;
const int N=2e5+5;
const int M=2e2+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int n,m;
char str[N];
int f[N];
bool vis[M][M];
map<int,pt> mm;
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    n=3;
    FOR(i,1,n){
        FOR(j,1,n){
            int a; r(a);
            mm[a]=mp(i,j);
        }
    }
    r(m);
    while(m--){
        int a;
        r(a);
        if(mm.count(a)) vis[mm[a].fi][mm[a].se]=1;
    }
    bool flag=1;
    FOR(i,1,n){
        bool ff=1;
        FOR(j,1,n){
            if(vis[i][j]==0){
                ff=0;
                break;
            }
        }
        if(ff){
            flag=0;
            break;
        }
    }
    FOR(i,1,n){
        bool ff=1;
        FOR(j,1,n){
            if(vis[j][i]==0){
                ff=0;
                break;
            }
        }
        if(ff){
            flag=0;
            break;
        }
    }
    bool ff=1;
    FOR(i,1,n){
        if(vis[i][i]==0){
            ff=0;
            break;
        }
    }
    if(ff){
        flag=0;
    }
    ff=1;
    FOR(i,1,n){
        if(vis[i][n-i+1]==0){
            ff=0;
            break;
        }
    }
    if(ff){
        flag=0;
    }
    if(flag==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

const int N = 1e6;
vector<int> primes;
void sieve(){
    bitset<N+1> bs;
    bs.set();
    bs[0] = bs[1] = 0;
    for(ll i = 2; i * i <= N; ++i){
        if(bs[i]){
            for(ll j = i * i; j <= N; j += i){
                bs[j] = 0;
            }
            primes.push_back((int)i);
        }
    }
}
ll div(int x){
    ll num = 1;
    for(auto prime : primes){
        if(prime * prime > x){
            break;
        }
        ll cnt = 0;
        while(x % prime == 0){
            x /= prime;
            ++cnt;
        }
        num *=  (cnt + 1);
    }
    if(x != 1){
        num *= 2;
    }
    return num;
}
void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int c = 1; c <= n - 1; ++c){
        ans += div(n - c);
    }
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    sieve();
    solve();
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  ll ma = 0, mi = INF, a;
  for (int i = 0; i < n; i++){
    cin >> a;
    ma = max(ma, a);
    mi = min(mi, a);
  }

  cout << ma - mi << endl;

  return 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    int N; cin >> N;
    vector<int> R(N);
    for(int i = 0; i < N; i++) {
        cin >> R[i];
    }

    int minv = R[0];
    int maxv = R[1] - R[0];
    for(int i = 1; i < N; i++) {
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


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

int mapInfo[1000][1000];

int main()
{
	int n;
	while(cin >> n, n)
	{
		for(int y = 0; y < n; y++)
		{
			for(int x = 0; x < n; x++)
			{
				char input;
				cin >> input;
				mapInfo[x][y] = input == '.' ? 1 : 0;
			}
		}
		
		for(int y = 1; y < n; y++)
		{
			for(int x = 1; x < n; x++)
			{
				if(mapInfo[x][y] == 0) continue;
				mapInfo[x][y] = min({mapInfo[x - 1][y - 1], mapInfo[x - 1][y], mapInfo[x][y - 1]}) + 1;
			}
		}
		
		int max_ = 0;
		for(int y = 0; y < n; y++)
		{
			for(int x = 0; x < n; x++)
			{
				max_ = max(max_, mapInfo[x][y]);
			}
		}
		
		cout << max_ << endl;
		
	}
	
	
	return 0;
}

Measured memory_bytes: 6896
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = [0] + readInts()
cum = list(accumulate(A))

dic = defaultdict(int)
for i in range(len(cum)):
    dic[cum[i]] += 1
ans = 0
for k,v in dic.items():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 45344