akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;

int N;
ve<string> ans;
void dfs(int n,ve<char> A, string s,int b){
    ve<char> B = A;
    B.pb(char(A.back()+1));
    if(n == N){
        ans.pb(s);
    }else{
        for (int i = 0; i < b; i++) {
            dfs(n+1,B,s+A[i],b);
        }
        dfs(n+1,B,s+A[b],b+1);
        
    }
}


int main()
{
    cin >> N;
    dfs(0,{'a'},"",0);
    
    sort(all(ans));
    rep(i,ans.size()) cout << ans[i] << endl;

    //cout << ans.size() << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 7796
import java.util.*;

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

        long a = sc.nextLong();
        long b = sc.nextLong();

        if (a == 1 || b == 1) {
            System.out.println(1);
            return;
        }

        System.out.println((a * b + 1) / 2);
    }

}

Measured memory_bytes: 21844
#include <cstdio>

/*
max(N- [x2, ..., xN] [ 1 2 3 4 ... 4 3 2], 0)

(1 + z + z^2 + ... + z^N) (1 + z^2 + z^4 + ... + z^{2N}) ...
f(z) = 1/[(1-z){(1-z^2)(1-z^3)...(1-z^{N/2})}^2]


[z^N] (N f(z) - z * f'(z))/(1-z)
[z^N] (f(z)(N - z * f'(z)/f(z)))/(1-z)

f'(z)/f(z) = 1/(1-z) + 2(2z/(1-z^2) + 3z^2/(1-z^3) + ...

log f = \sum_{i=2}^{N/2}

f(z) = (1-z)(1-z^{N/2+1})^2(1-z^{N/2+2})^2... / [(1-z)(1-z^2)...]^2
f(z) = (1-z)(1-2z^{N/2+1})(1-2z^{N/2+2})... / [(1-z)(1-z^2)...]^2
f(z) = (1-z)(1-2z^{N/2+1}-2z^{N/2+2}-...) / [(1-z)(1-z^2)...]^2
f(z) = (1-z-2z^{N/2+1}) / [(1-z)(1-z^2)...]^2

*/

int n, m;

int dp[5001];

int main(){
  scanf("%d%d", &n, &m);

  dp[0] = 1;
  dp[1] = m-1;
  dp[(n+1)/2+1] = m-2;


  if(n & 1){
    dp[(n+1)/2] -= 1;
    dp[(n+1)/2+1] += 1;
    if(dp[(n+1)/2] < 0) dp[(n+1)/2] += m;

/*
    for(int i = n; i >= (n+1)/2; i--){
      dp[i] -= dp[i-(n+1)/2];
      if(dp[i] < 0) dp[i] += m;
    }
*/
  }
  for(int i = 0; i <= n; i++){
    for(int j = 1; ; j++){
      int k = j * (3 * j - 1) / 2;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
      k += j;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
    }
  }
  for(int i = 0; i <= n; i++){
    for(int j = 1; ; j++){
      int k = j * (3 * j - 1) / 2;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
      k += j;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
    }
  }

/*
  for(int i = 0; i <= n; i++) dp[i] = 1;
  for(int i = 2; i <= n/2; i++){
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
  }
 

  if(n & 1){
    for(int j = (n+1)/2; j <= n; j++){
      dp[j] += dp[j-(n+1)/2];
      if(dp[j] >= m) dp[j] -= m;
    }
  }
*/

  int c = 0;
  for(int i = 0; i <= n; i++){
    c = (c + (long long) (n - i) * dp[i]) % m;
  }

  printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 128
N=int(input())
a=list(map(int,input().split()))
D=dict()
for i in range(N):
    if a[i] in D:
        D[a[i]]+=1
    else:
        D[a[i]]=1
L=list(D.items())
L.sort()
#print(L)

if len(L)==1:
    if L[0][0]==0:
        print("Yes")
        exit()
elif len(L)==2:
    if L[0][0]==0 and L[1][1]==L[0][1]*2:
        print("Yes")
        exit()
elif len(L)==3:
    #print(1)
    if L[0][1]==L[1][1] and L[1][1]==L[2][1]:
        #print(2)
        if L[1][0]==L[0][0]^L[2][0] and L[2][0]==L[1][0]^L[0][0] and L[0][0]==L[1][0]^L[2][0]:
            print("Yes")
            exit()
print("No")
            


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

using namespace std;
#define ll long long
#define f first
#define s second
int cum[100005];
int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        cum[a]++;
        cum[b+1]--;
    }
    int sum=0;
    int res=0;
    for(int i=0;i<100003;i++){
        sum+=cum[i];
        cum[i]=sum;
        if(sum==m){
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
k = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k - 1])

Measured memory_bytes: 3060
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

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

}

ll N;
vector<ll> A;
vector<pll> retu;
int main() {

	cin >> N;

	A.resize(N);
	rep(i, N) {

		cin >> A[i];
		retu.push_back({ A[i], i });
	}

	sort(retu.begin(), retu.end());
	ll ans = 0;
	rep(i, N) {
		if (retu[i].second % 2 != i % 2) {
			ans += 1;
		}

	}

	cout << ans / 2 << endl;


	return 0;
}

Measured memory_bytes: 3188
N,M=gets.split.map(&:to_i)
x,y=M.times.map{gets.split.map{|e|e.to_i-1}}.transpose
pos=Array.new(N,false)
cnt=Array.new(N,1)
pos[0]=true
M.times do |i|
    pos[y[i]]=true if pos[x[i]]
    cnt[y[i]]+=1
    cnt[x[i]]-=1
    pos[x[i]]=false if cnt[x[i]]==0
end
res=0
N.times do |i|
    res+=1 if pos[i]
end
puts res

Measured memory_bytes: 12668
flag=True
s = input()
if len(s)!=0:
    for i in range(1,len(s)):
        if s[i-1]==s[i]:
            print(str(i)+" "+str(i+1))
            flag=False
            break
        if i>1:
            if s[i-2]==s[i]:
                print(str(i-1)+" "+str(i+1))
                flag=False
                break
    if flag:
        print("-1 -1")            
else:
    print("-1 -1")

Measured memory_bytes: 3188
//http://mujin-pc-2017.contest.atcoder.jp/tasks/mujin_pc_2017_c
#include <bits/stdc++.h>

using namespace std;

const int maxn = 500100;
const int maxj = 30;

int nextc[maxn][30],f[maxn][maxj],a[maxn],n,q;
string s;

int main() {
    ios_base::sync_with_stdio(0);
   // freopen("in.txt","r",stdin);
    cin>>s;
    int n = s.length();
    for (int i=0;i<n;i++) a[i] = s[i] - 'a';
    for (int i=0;i<=n;i++)
        for (int c=0;c<=26;c++)
            nextc[i][c]=-1;
    //cout<<"fuck"<<endl;
    for (int i=n-1;i>=0;i--) {
        nextc[i][a[i]] = i+1;
        for (int c=a[i]+1;c<=26;c++)
            if (nextc[i][c-1]!=-1) nextc[i][c] = nextc[nextc[i][c-1]][c-1];
        for (int c=0;c<a[i];c++)
            if (nextc[i][26]!=-1) nextc[i][c] = nextc[nextc[i][26]][c];
    }
  //  for (int i=0;i<n;i++) {
  //      for (int j=0;j<=26;j++) cout<<nextc[i][j]<<" ";
   //     cout<<endl;
  //  }
   // cout<<"fuck"<<endl;
    for (int i=0;i<=n;i++) f[i][0] = nextc[i][26];
    for (int j=1;j<maxj;j++)
        for (int i=0;i<=n;i++) {
            if (f[i][j-1]==-1) f[i][j]=-1;
            else f[i][j] = f[f[i][j-1]][j-1];
        }
    //cout<<"fuck"<<endl;
  //  for (int i=0;i<n;i++) {
   //     for (int j=0;j<maxj;j++) cout<<f[i][j]<<" ";
   //     cout<<endl;
  //  }
    cin>>q;
    int x,y;
    for (int i=1;i<=q;i++) {
        cin>>x>>y;
        x--;
       // cout<<x<<" "<<y<<endl;
        for (int j=maxj-1;j>=0;j--) {
            if (f[x][j]==-1) continue;
            if (f[x][j]<=y) {
                x = f[x][j];
            }
        }
       // cout<<x<<" "<<y<<endl;
        if (x>=y) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 120348
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
A.sort()
if N % 2 == 0:
	print(-2*sum(A[:N//2-1]) + 2*(sum(A[N//2+1:])) + A[N//2] - A[N//2-1])
	exit()

a = 2*sum(A[N//2+1:]) - 2*sum(A[:N//2-1]) - A[N//2] - A[N//2-1]
b = 2*sum(A[N//2+2:]) - 2*sum(A[:N//2]) + A[N//2] + A[N//2+1]
print(max(a,b))


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

int main(){
	int k, s; cin >> k >> s;
	long long ans = 0;
	for(int x = 0; x <= k; ++x){
		int dec = s - x;
		if(dec < 0){
			continue;
		}
		if(dec >= k){
			dec -= k;
			if(dec > k){
				continue;
			}else{
				ans += k - dec + 1;
			}
		}else{
			ans += dec + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

int main(){
    int N;
    cin >> N;
    vector<ll> L(N);
    for (int i = 0; i < N; i++) cin >> L.at(i);

    sort (L.begin(), L.end());
    ll ans = 0;

    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (L.at(i) == L.at(j)) continue;
            for (int k = j + 1; k < N; k++) {
                if (L.at(i) == L.at(k) || L.at(j) == L.at(k)) continue;
                if (L.at(i) + L.at(j) > L.at(k)) ans++;
            }
        }
    }

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

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator+(const Point p) const {
		return Point(x + p.x, y + p.y);
	}
	Point operator-(const Point p) const {
		return Point(x - p.x, y - p.y);
	}
	Point operator*(double k) const {
		return Point(x*k, y*k);
	}
};
Point operator*(double k, const Point p) {
	return Point(p.x*k, p.y*k);
}
typedef Point Vector;
struct Line {
	Point p1, p2;
	Line(Point p1 = Point(), Point p2 = Point()) :p1(p1), p2(p2) {}
};
struct Result {
	int type;
	Point p;
	Line l;
};
double dot(Vector a, Vector b) {
	return a.x*b.x + a.y*b.y;
}
double cross(Vector a, Vector b) {
	return a.x*b.y - a.y*b.x;
}
double norm(Vector v) {
	return v.x*v.x + v.y*v.y;
}
Point project(Line l, Point p) {
	Vector base = l.p2 - l.p1;
	double r = dot(p - l.p1, base) / norm(base);
	return l.p1 + base*r;
}
Point reflect(Line l, Point p) {
	return p + (project(l, p) - p)*2.0;
}
Point getCrossPoint(Line l1, Line l2) {
	double A = cross(l1.p2 - l1.p1, l2.p2 - l2.p1);
	double B = cross(l1.p2 - l1.p1, l1.p2 - l2.p1);
	return l2.p1 + B / A*(l2.p2 - l2.p1);
}
char s[101];
int pos;
Result term() {
	Result r;
	int cnt = 0;
	while (1) {
		Result t;
		pos++;
		if (s[pos] == '-' || isdigit(s[pos])) {
			bool minus = 0;
			if (s[pos] == '-') {
				minus = 1;
				pos++;
			}
			int x = 0;
			while (isdigit(s[pos])) {
				x *= 10;
				x += s[pos] - '0';
				pos++;
			}
			if (minus) x *= -1;
			pos++;
			int y = 0;
			minus = 0;
			if (s[pos] == '-') {
				minus = 1;
				pos++;
			}
			while (isdigit(s[pos])) {
				y *= 10;
				y += s[pos] - '0';
				pos++;
			}
			if (minus) y *= -1;
			pos++;
			t.type = 0;
			t.p = Point(x, y);
		}
		else {
			t = term();
		}
		if (cnt == 0) {
			r = t;
		}
		else if (r.type == 0 && t.type == 0) {
			Point p1 = r.p;
			Point p2 = t.p;
			r.type = 1;
			r.l.p1 = p1;
			r.l.p2 = p2;
		}
		else if (r.type == 0 && t.type == 1) {
			Point p = r.p;
			Line l = t.l;
			r.type = 0;
			r.p = reflect(l, p);
		}
		else if (r.type == 1 && t.type == 0) {
			Point p = t.p;
			Line l = r.l;
			r.type = 0;
			r.p = reflect(l, p);
		}else {
			Line l1 = r.l;
			Line l2 = t.l;
			r.type = 0;
			r.p = getCrossPoint(l1, l2);
		}
		if (s[pos] != '@') break;
		pos++;
		cnt++;
	}
	pos++;
	return r;
}
int main() {
	while (cin >> s, s[0] != '#') {
		pos = 0;
		Result r = term();
		printf("%.15lf %.15lf\n", r.p.x, r.p.y);
	}
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

//幅優先探索
string bfs(vector<pair<int,int>> *edge, int *x, int *visit, int N){
  for(int i = 0; i < N; ++i){
    if(visit[i] == 1){
      continue;
    }
    visit[i] = 1;
    x[i] = 0;
    queue<int> que;
    que.push(i);
    while(!que.empty()){
      int q = que.front();                        //キューの先頭要素qを始点とする
      que.pop();
      for(auto &p : edge[q]){                         //頂点qを始点とする全ての枝について走査
        if(visit[p.first] == 1){                  //枝の終点が訪問済みの場合
          if(x[q] + p.second != x[p.first]){      //x[始点]+枝の重みがx[終点]と不一致
            return "No";                             //forループ脱出
          }
        }else{                                    //枝の終点が訪問済みでない場合
          x[p.first] = x[q] + p.second;           //終点のx座標を始点のx座標+枝の重みとする
          visit[p.first] = 1;                     //フラグを立て類
          que.push(p.first);                      //終点をキューに追加
        }
      }
    }
  }
  return "Yes";
}

int main(){
  int N, M, L, R, D = 0;
  cin >> N >> M;
  //重み付き有向グラフ
  //N人の人がグラフの各頂点となる
  //L->Rの向きに重みDの枝，R->Lの向きに重み-Dの枝を持つ
  //Edge[始点]に{終点, 重み}を保持
  vector<pair<int, int>> *edge = new vector<pair<int, int>>[N];
  for(int i = 0; i < M; ++i){
    cin >> L >> R >> D;
    --L; --R;
    edge[L].push_back({R, D});
    edge[R].push_back({L, -D});
  }

  int *visit = new int[N];     //走査済みの頂点を表す
  int *x = new int[N];         //頂点の持つ値(x座標)
  for(int i = 0; i < N; ++i){
    visit[i] = 0;
    x[i] = 0;
  }

  cout << bfs(edge, x, visit, N) << endl;
  delete[] edge; delete[] x; delete[] visit;
  return 0;
}


Measured memory_bytes: 9728
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

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

using ll = long long;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	n += 1;
	vector<vector<ll> > a(n, vector<ll>(n, 0));
	for(int i = 1; i < n; i++){
		for(int j = 1; j < n; j++){
			if(i == j) continue;
			cin >> a[i][j];
		}
	}
	vector<vector<ll> > rsum(n, vector<ll>(n, 0));
	vector<vector<ll> > lsum(n, vector<ll>(n, 0));
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			rsum[i][j] = rsum[i][j-1];
			lsum[i][j] = lsum[i][j-1];
			for(int k = i; k < j; k++){
				rsum[i][j] += a[k][j];
				lsum[i][j] += a[j][k];
			}
		}
	}
	vector<vector<ll> > dp(n, vector<ll> (n, 2e18));
	dp[0][0] = 0;
	for(int j = 0; j < n; j++){
		for(int i = 0; i <= j; i++){
			for(int k = j+1; k < n; k++){
				ll newdp = dp[i][j];
				newdp += rsum[j+1][k];
				newdp += lsum[0][k] - lsum[0][j] - lsum[i][k] + lsum[i][j];
				dp[j+1][k] = min(dp[j+1][k], newdp);
			}
		}
	}
	ll ans = 2e18;
	for(int i = 0; i < n; i++){
		ans = min(ans, dp[i][n-1]);
	}
	cout << ans << '\n';
}

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

int main(){
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int h,w;
  cin >> h >> w;
string d[50];
  
  for(int i=0;i<h;i++) cin >> d[i];
int num;  
for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
  if(d[i][j]=='.')continue;
   num=0; 
   for(int k=0;k<4;k++){
    int y=i+dy[k];
    int x=j+dx[k];
   if(y<0 | y>=h)continue;
   if(x<0 | x>=w)continue;
   if(d[y][x]=='#')num++;  
   }
   if(num==0)break; 
  }
  if(num==0)break;
}  
if(num==0)cout << "No" << endl;  
else cout << "Yes" << endl;  
  
}

Measured memory_bytes: 3604
import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))
def fact25(n):
    cnt2=0
    cnt5=0
    while n%2==0:
        n//=2
        cnt2+=1
    while n%5==0:
        n//=5
        cnt5+=1
    return cnt2,cnt5

arr = [[0 for _ in range(20)] for _ in range(20)]
p25 = []
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    p25.append([cnt2,cnt5])
    cnt2=min(19,cnt2)
    cnt5=min(19,cnt5)
    arr[cnt2][cnt5]+=1

ans=0
for i in range(20): # 2
    for j in range(20): # 5
        if arr[i][j]==0:
            continue
        for k in range(20): # 2
            for l in range(20): # 5
                if i+k>=18 and j+l>=18:
                    if i==k and j==l:
                        ans+= (arr[i][j]-1)*arr[k][l]
                    else:
                        ans+= arr[i][j]*arr[k][l]

print(ans//2)

Measured memory_bytes: 284536
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
/*配列Aに含まれる要素の異なる数字毎にカウントし、奇数個ある数字の個数が答え*/
int main() {
	int A,B;
	cin >> A >> B;
	int ans = 0;
	
	if(2*B >= A) ans = 0;
	else ans = A - 2*B;

	cout << ans << endl;
}

Measured memory_bytes: 256
INF = 10**10
n,t = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
cost = 0
l = 0
r = 1
while r<n:    
  dif = A[r] - A[l]
  if dif == cost:
    ans += 1
  elif dif > cost :
    cost = dif
    ans = 1 
  else:
    pass
  if dif <= 0:
    l = r
  r += 1
  
print(ans)  

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

using namespace std;

int main() {
    int A, B, C, K;

    cin >> A >> B >> C >> K;

    int xa = min(A, K);
    K -= xa;
    int xb = min(B, K);
    K -= xb;
    int sum = xa - K;

    cout << sum << endl;
}


Measured memory_bytes: 3620
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll a[MX+10];
ll isUsed[MX+10];
ll fn(ll x){
    return a[x-1];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    rp(i,n) cin >> a[i];
    ll cur = 1;
    isUsed[1] = 1;
    ll ans = 0;
    while(cur != 2){
        cur = fn(cur);
        ans ++;
        if(isUsed[cur] == 1) {cout << "-1"<<endl; return 0;}
        isUsed[cur]=1;
    }

    cout << ans <<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;


int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    sort(A.rbegin(), A.rend());

    ll ans = 0;
    rep(i,N){
        if (i == 0) continue;
        ans += A[i/2];
    }

    cout << ans << endl;

}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
int main(void){
  signed long long x,k,d;cin>>x>>k>>d;x=abs(x);
  signed long long y = x/d;
  if(y>k) cout<<x-k*d<<endl;
  else{
    x -= y*d;
    k -= y;
    if(k&1) cout<<abs(x-d)<<endl; else cout<<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
import math

def solve(X: int):
#    n = math.log(X / 100.0) / math.log(1.01)
#    N = math.ceil(n)

    N = 0
    Y = 100
    while(Y < X):
        Y = math.floor(Y * 1.01)
        N += 1
    print(N)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    long[] sa = new long[n + 1];
    long sum = 0;
    long[] ab = new long[n + 1];
    sa[0] = a[0];
    sa[n] = (-1) * a[n - 1];
    ab[0] = Math.abs(sa[0]);
    ab[n] = Math.abs(sa[n]);
    sum = ab[0] + ab[n];
    for(int i = 1; i < n; i++) {
      sa[i] = a[i] - a[i - 1];
      ab[i] = Math.abs(sa[i]);
      sum += ab[i];
    }
    for(int i = 0; i < n; i++) {
      long t = sum - ab[i] - ab[i + 1];
      t += (Math.abs(sa[i + 1] + sa[i]));
      System.out.println(t);
    }
  }
}

Measured memory_bytes: 63196
def main():
    X, K, D = map(int, input().split())

    val = [0] * 100000000
    val[0] = X
    #val = X
    #val_new = 0
    if K % 2 == 0 :
        limit = 4
    else :
        limit = 5
    i = 0
    if abs(X) > K * D :
        if X > 0 :
            print(X - K * D)
        else :
            print(abs(X + K * D))
    elif abs(X) == K * D :
        print("0")
    elif X == 0 :
        if limit == 4 :
            print('0')
        else :
            print(abs(D))
    else :
        syo = abs(X) // D
        #print(syo)
        if syo > 3 :
            if X > 0 :
                val[0] = X - (syo-2) * D
            else :
                val[0] = X + (syo - 2) * D
            #print(val[0])
            K = K -(syo-2)
            if K % 2 == 0:
                limit = 2
            else:
                limit = 3
        for j in val :
            #print(i)
            if abs(val[i] - D) < abs(val[i] + D) :
                val[i+1] = val[i] - D
            else :
                val[i+1] = val[i] + D
            #print(val[i+1])
            if (abs(val[i+1]) == abs(val[i-1])) and i > limit :
                #print("a")
                print(abs(val[i + 1]))
                break
            i += 1
            if i == K :
                #print("b")
                print(abs(val[i]))
                break


if __name__ == '__main__':
    main()


Measured memory_bytes: 790144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	int A, B;
	cin >> A >> B;
	if (B%A == 0) cout << A + B << endl;
	else cout << B-A << endl;


	return 0;
}

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

int n,m;
int p[200002];
int cnt_p[200002];
int max_p = 1;

int parent(int x){
	if(p[x] != x){
		return(p[x] = parent(p[x]));
	}
	return(x);
}

void uni(int x,int y){
	if(parent(x) != parent(y)){
		int tmp = cnt_p[parent(y)];
		p[parent(y)] = parent(x);
		cnt_p[parent(x)] += tmp;
		if(max_p < cnt_p[parent(x)]){
			max_p = cnt_p[parent(x)];
		}
	}
}

int main(){

	cin>>n>>m;
	for(int i=0;i<=n;i++){
		p[i] = i;
		cnt_p[i] = 1;
	}

	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(b<a){
			uni(b,a);
		}
		else{
			uni(a,b);
		}
	}

	cout<<max_p<<endl;

	return(0);
}

Measured memory_bytes: 5200
//2018.9.22 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    int n,l;
    int a[N];
    int tot;
    int step[N],stepx;
    inline void MAIN(){
        n=read(),l=read();
        for(res i=1;i<=n;i++)a[i]=read();
        res j=1;
        for(res i=1;i<n;i++)if(a[i]+a[i+1]>a[j]+a[j+1])j=i;
        if(a[j]+a[j+1]<l)puts("Impossible");
        else {
            puts("Possible");
            for(res i=n-1;i>j;i--)printf("%d\n",i);
            for(res i=1;i<=j;i++)printf("%d\n",i);
        }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
string s;
int k;
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> k >> s;
    if(k >= s.length()){
        cout << s;
    }
    else cout << s.substr(0,k) << "...";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main(){
  // 入力
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  string result;
  while (true) {
    C = C - B;
    if (C <= 0) {
      result = "Yes";
      break;
    }
    A = A - D;
    if (A <= 0) {
      result = "No";
      break;
    }
  }

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

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string.h>

#define loop(lp) for(int lp2 = 0; lp2 < lp; lp2 ++)
#define ascent(i, a, b) for(int i = a; i < b; i ++)

#define pb push_back

using namespace std;

int dp[100][100];

int main() {
  int a, b;
  while(cin >> a >> b, a,b) {
    int n;
    cin >> n;
    
    vector<pair<int, int> > acc;
    loop(n) {
      int x, y;
      cin >> x >> y;
      acc.pb(make_pair(x, y));
    }
    
    memset(dp, 0, sizeof(dp));
    dp[1][1] = 1;
    
    ascent(x, 1, a+1) {
      ascent(y, 1, b+1) {
	bool flg = true;
	ascent(i, 0, n) {
	  if(x == acc[i].first && y == acc[i].second) {
	    dp[x][y] = 0;
	    flg = !flg;
	    
	    break;
	  }
	}
	
	if(flg) {
	  if(x == 1 && y == 1) { continue; }
	  else if(x == 1) {
	    dp[x][y] = dp[x][y-1];
	  }
	  else if(y == 1) {
	    dp[x][y] = dp[x-1][y];
	  }
	  else {
	    dp[x][y] = dp[x-1][y] + dp[x][y-1];
	  }
	}
      }
    }
    
    cout << dp[a][b] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1244
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var ABCD = Sarray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];
            var ans = 0L;
            if (B <= D)
                ans = Min(B - A, Max(0, B - C));
            else
                ans = Max(0, Min(D - A, D - C));
            WriteLine(ans);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27948
x, y = [int(_) for _ in input().split()]
ABC = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i in range(3):
    if x in ABC[i] and y in ABC[i]:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

int W,H,N;
bool fld[6100][6100];
int X1[1000],X2[1000],Y1[1000],Y2[1000];
const int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};

int compress(int *x1,int *x2,int w){
	vector<int> xs;
	for(int i=0;i<N;i++){
		for(int j=-1;j<=0;j++){
			int tx1=x1[i]+j,tx2=x2[i]+j;
			if(0<=tx1 && tx1<w)xs.push_back(tx1);
		}
		x2[i]--;
		for(int j=0;j<=1;j++){
			int tx2=x2[i]+j;
			if(0<=tx2 && tx2<w)xs.push_back(tx2);
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	for(int i=0;i<N;i++){
		x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
	}
	return xs.size();
}

void solve(){
	W=compress(X1,X2,W);
	H=compress(Y1,Y2,H);
	memset(fld,0,sizeof(fld));
	for(int i=0;i<N;i++){
		for(int y=Y1[i];y<=Y2[i];y++){
			for(int x=X1[i];x<=X2[i];x++){
				fld[y][x]=true;
			}
		}
	}

	long long int ans=0;
	for(int y=0;y<H;y++){
		for(int x=0;x<W;x++){
			if(fld[y][x])continue;
			ans++;

			queue<pair<int, int> > que;
			que.push(make_pair(x, y));
			while(!que.empty()){
				int sx=que.front().first,sy=que.front().second;
				que.pop();
				for(int i=0;i<4;i++){
					int tx=sx+dx[i],ty=sy+dy[i];
					if(tx<0 || W<=tx || ty<0 || H<=ty)continue;
					if(fld[ty][tx])continue;
					que.push(make_pair(tx, ty));
					fld[ty][tx]=true;
				}
			}
		}
	}
	printf("%d\n",ans);

}

int main(void){
	while(1){
		scanf("%d%d",&W,&H);
		if(W==0 && H==0)break;
		scanf("%d",&N);
		for(int i=0;i<N;i++){
			scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
		}
		solve();
	}
    return 0;
}

Measured memory_bytes: 37584
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        int N = nint();
        int W = nint();
        int[] ws = new int[N+1];
        int[] vs = new int[N+1];
        for (int i = 0; i < N; i++) {
            ws[i+1] = nint();
            vs[i+1] = nint();
        }
        
        long[][] sum = new long[N+1][W+1];
        for (int n = 1; n <= N; n++) {
            for (int w = 1; w <= W; w++) {
                int prevW = w - ws[n];
                int prevN = n - 1;
                
                if (prevW < 0) {
                    sum[n][w] = sum[prevN][w];
                } else {
                    sum[n][w] = max(sum[prevN][prevW] + vs[n], sum[prevN][w]);
                }
            }
        }
        System.out.println(sum[N][W]);
    }

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    @Deprecated
    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 331252
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    string  s; cin >> s ;
    map <char,int> cnt;
    for (int i=0;i<sz(s);i++)
        cnt[s[i]]++;
    for (char c='a';c<='z';c++){
        if (!cnt[c]){
            cout << c << endl;
            return;
        }
    }
    cout << "None" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

double eps = 10e-10;

struct Point {
    double x, y;

    Point() {
        x = 0;
        y = 0;
    }

    Point(const double x_, const double y_) {
        x = x_;
        y = y_;
    }
};

struct Line {
    Point a, b;

    Line(const Point& a_, const Point& b_) {
        a = a_;
        b = b_;
    }
};

Point crossPoint(Line l, Line m) {
    double alpha = ((m.a.y - l.a.y) * (m.b.x - m.a.x) + (m.b.y - m.a.y) * (l.a.x - m.a.x)) / ((l.b.y - l.a.y) * (m.b.x - m.a.x) - (m.b.y - m.a.y) * (l.b.x - l.a.x));
    double x = l.a.x + alpha * (l.b.x - l.a.x);
    double y = l.a.y + alpha * (l.b.y - l.a.y);
    return Point(x, y);
}

double dist(Point p, Point q) {
    return sqrt(pow(p.x - q.x, 2) + pow(p.y - q.y, 2));
}

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) break;

        vector<Line> lines;
        int n_area = 1;

        while (n--) {
            Point a, b;
            cin >> a.x >> a.y >> b.x >> b.y;
            Line l(a, b);

            int delta_area = 1;
            vector<Point> crosspts;
            for (size_t i = 0; i < lines.size(); ++i) {
                Point c = crossPoint(lines[i], l);
                if (!isfinite(c.x) || !isfinite(c.y)) continue;
                if (c.x <= -100 || 100 <= c.x || c.y <= -100 || 100 <= c.y) continue;

                bool found = false;
                for (size_t j = 0; j < crosspts.size(); ++j) {
                    if (dist(crosspts[j], c) < eps) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    crosspts.push_back(c);
                    delta_area++;
                }
            }
            n_area += delta_area;

            lines.push_back(l);
        }

        cout << n_area << endl;
    }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX_V=120,MAX=1<<29;

struct edge{
  ll to,cap,rev;
};
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(ll from,ll to,ll cap) {
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

ll dfs(ll v,ll t,ll f) {
  if(v==t) return f;
  used[v]=true;
  for(int i=0; i<G[v].size(); i++) {
    edge &e=G[v][i];
    if(!used[e.to] && e.cap>0) {
      ll d=dfs(e.to,t,min(f,e.cap));
      if(d>0) {
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(ll s,ll t) {
  ll flow=0;
  for(;;) {
    memset(used,0,sizeof(used));
    ll f=dfs(s,t,MAX);
    if(f==0) return flow;
    flow+=f;
  }
}
int main() {
  ll n,m;
  while(cin >> n >> m && n) {
    for(int i=0; i<MAX_V; i++) G[i].clear();
    for(int i=0; i<7; i++) add_edge(110,100+i,m);
    ll sum=0;
    for(int i=0; i<n; i++) {
      ll x,y;
      cin >> x >> y;
      sum+=x;
      add_edge(i,111,x);
      for(int j=0; j<y; j++) {
        string t;
        cin >> t;
        if(t=="Sunday") add_edge(100,i,x);
        if(t=="Monday") add_edge(101,i,x);
        if(t=="Tuesday") add_edge(102,i,x);
        if(t=="Wednesday") add_edge(103,i,x);
        if(t=="Thursday") add_edge(104,i,x);
        if(t=="Friday") add_edge(105,i,x);
        if(t=="Saturday") add_edge(106,i,x);
      }
    }
    if(max_flow(110,111)==sum) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

int main(){
  int n,t;cin>>n;
  set<int> a;
  
  rep(i,n){
    cin>>t;
    if(a.count(t))a.erase(t);
    else a.insert(t);
  }
  cout<<a.size()<<endl;
  
}

Measured memory_bytes: 8312
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def countstep(a):
    i = 0
    while a>=i+1:
        i += 1
        a -= i
    return i

def main():
    n = int(input())
    a = factorization(n)
    
    if n==1:
        print(0)
        return
    
    if a[0][0]==0:
        print(0)
    else:
        count = 0
        for i in range(len(a)):
            count += countstep(a[i][1])
        print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9404
#include<bits/stdc++.h>
 
#define ll long long int 
#define endl '\n'
#define PI  3.14159265358979323846
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MAX 1000
using namespace std;
 
//ll gcd(ll n,ll m){
//	if(m==0)
//	return n;
//	if(n<m)
//	swap(n,m);
//	while(n%m!=0)
//	{
//		ll temp=n;
//		n=m;
//		m=temp%m;
//	}
//	return m;
//}

//bool sortbysec(pair<int,int> &a,pair<int,int> &b) 
//{ 
//    return (a.second < b.second); 
//} 


int main() {
    ll n,i,j;
    cin>>n;
    ll a[n][3],dp[n][3];
    for(i=0;i<n;i++)
    {
    	for(j=0;j<3;j++)
    	cin>>a[i][j];
	}
	for(i=0;i<3;i++)
	{
		dp[0][i]=a[0][i];
	}
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
		}
	}
	ll ans= *max_element(dp[n-1],dp[n-1]+3);
	cout<<ans;
}






Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)) {
    cout << "A" << endl;
  }
  else {
    cout << "B" << endl;
  }
}

Measured memory_bytes: 256
import numpy as np

# input
H, N = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(N)]
A, B = np.array(AB, dtype=np.int64).reshape(N, 2).T

# process
dp = np.zeros(H+1, dtype=np.int64)
dp[0] = 0

for i in range(1, H + 1):
    dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)

# output
print(dp[H])


Measured memory_bytes: 12612
#include<cstdio>
#define N 20002
#define F for(register int i(1);i<=n;i++)
int n,a[N],b[N];
signed main()
{
	scanf("%d",&n);int t;
	F
		a[i]=i*N,b[i]=(n-i+1)*N;
	F
		scanf("%d",&t),a[t]-=(n-i+1);
	F
		printf("%d ",a[i]);
	puts("");
	F
		printf("%d ",b[i]);
	return puts(""),0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
int ara_D[100][200];
int ara[100000];
char ara1[100000];
int main()
{
    long long i,j,a,b,n,num,cnt=0;
    scanf("%lld %lld %lld",&a,&b,&num);
    /*for(i=a,j=num;i<=b;i++)
    {
        if(i%num==0)
        {
            cnt++;
            for(n=num+num;n<=b;n+=num)
            {
                cnt++;
            }
            break;
        }
    }*/
    if(a==0)
    {
        i=b/num;
        j=1;
        cnt=i+j;
    }
    else
    {
        i=b/num;
        j=(a-1)/num;
        cnt=i-j;
    }
    printf("%lld\n",cnt);
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c,x,y;
    cin>>n>>m;
    int a[n+1][n+1];
    int i,j;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
        {
            a[i][j]=0;
        }
    }
    while(m--)
    {
        cin>>x>>y;
        a[x][y]++;
        a[y][x]++;

    }
    for(i=1;i<=n;i++)
    {
        c=0;
        for(j=1;j<=n;j++)
        {
            if(a[i][j]!=0)
                c=c+a[i][j];
        }
        cout<<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF -1
#define W 0
#define G 1
#define B 2
#define N 100000
int n,Q[100],M[100][100];
int color[100],d[100],f[100],tail=0,head=0;

void visit(int);
void bfs(int);
void enqueue(int);
int dequeue();

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  bfs(0);

  return 0;
      
}

void bfs(int s){
  int i,u,v;
  for(u=0;u<n;u++){
    color[i] = W;
    d[u] = INF;
  }
  color[s] = G;
  d[s] = 0;
  enqueue(s);

  while (head != tail){
    u = dequeue();
    for(v=0;v<n;v++){
      if(M[u][v]==1){
	if( color[v] == W){
	  color[v] = G;
	  d[v]= d[u] + 1;
	  enqueue(v);
	}
      }
    }
    color[u]=B;
  }
    for(i=0;i<n;i++){
      printf("%d %d\n",i+1,d[i]);
    }
  

}

void enqueue(int x){
  
  Q[tail] = x;
  if(tail+1 == N){
    tail = 0;
  }
  else{
    tail++;
  }
}
 
int dequeue(){
  int x;
  x = Q[head];
  if((head +1) == N){
    head = 0;
  }
  else {
    head++;
  }
  return x;
}



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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    cin >> n;

    int mn = n + 1, ans = 0;
    while (n--) {
        int x;
        cin >> x;
        if (x < mn) mn = x, ans++;
    }

    cout << ans;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3624
f x y z = 5^x * 3^y * 2^z

ans2 v5 v3 m n =
  let max = floor $ logBase 2.0 ( fromIntegral(n) / (5.0^v5) / (3.0^v3) )
      res = filter (\v2 -> (f v5 v3 v2) >= m && (f v5 v3 v2) <= n) [0..max]
      ans = map (\v2 -> (v5,v3,v2)) res
  in
    length(res)

ans3 v5 m n =
  let max = floor $ logBase 3.0 ( fromIntegral(n) /  (5.0^v5) )
      res = map (\v3 -> ans2 v5 v3 m n) [0..max]
  in
    sum res

ans5 (m:n:_) =
  let max = floor $ logBase 5.0 (fromIntegral n)
      res = map (\v5 -> ans3 v5 m n) [0..max]
  in
    sum $ res

main = do
  c <- getContents
  let i = takeWhile (/= [0]) $ map (map read) $ map words $ lines c :: [[Int]]
      o = map ans5 i
  mapM_ print o

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] == '-') ans--;
        else ans++;
    }
    cout << ans << endl;
}

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

int main(){
	
	int N;
	cin >> N;
	
	int ans1 = 1;
	int ans2 = 1;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		ans1 *= 3;
		if(num % 2 == 0){
			ans2 *= 2;
		}
	}
	
	cout << ans1 - ans2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
long long MOD = 1e9 + 7;
long long modpow(long long a, long long n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
    {
        long long t = modpow(a, n / 2);
        return t * t % MOD;
    }
    return a * modpow(a, n - 1) % MOD;
}

long long modinv(long long a)
{
    // mod is prime
    return modpow(a, MOD - 2);
}
int main()
{
    ll n;
    cin >> n;
    map<ll, ll> m;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    for (auto i : a)
    {
        ll tmp = i;
        for (int j = 2; j * j <= i; j++)
        {
            ll cnt = 0;
            while (tmp % j == 0)
            {
                tmp /= j;
                cnt++;
            }
            m[j] = max(m[j], cnt);
        }
        m[tmp] = max(m[tmp], 1LL);
    }
    ll lcm = 1;
    for (auto p : m)
    {
        lcm *= modpow(p.first, p.second);
        lcm %= MOD;
    }
    ll res = 0;
    for (auto i : a)
    {
        ll inv = modinv(i);
        res += lcm * inv;
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){

	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}if(a>b){
		cout<<"a > b"<<endl;
	}if(a==b){
		cout<<"a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156