akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: u64
    };
    let divs = divisors(n).into_iter()
        .map(|x| x - 1)
        .filter(|&x| n / (x + 1) < x)
        .collect::<Vec<_>>();
    let sum = divs.iter().fold(0, |acc, &x| acc + x);
    println!("{}", sum);
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn divisors(n: u64) -> Vec<u64> {
    let mut ret = vec![];
    for i in (1..).take_while(|i| i * i <= n) {
        if n % i == 0 {
            ret.push(i);
            if i != n / i {
                ret.push(n / i);
            }
        }
    }
    ret
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<vector>
#include<utility>
#include<functional>
using namespace std;
const int INF=1e9;
const int ADD=1200;
typedef pair<int,int> P;
struct edge
{
    int to,cap,cost,rev;
};
int V;
vector<edge> G[505];
int h[505];
int dist[505];
int prevv[505],preve[505];
void add_edge(int from,int to,int cap,int cost)
{
    edge tmp;
    tmp.to=to,tmp.cap=cap,tmp.cost=cost,tmp.rev=G[to].size();
    G[from].push_back(tmp);
    tmp.to=from,tmp.cap=0,tmp.cost=-cost,tmp.rev=G[from].size()-1;
    G[to].push_back(tmp);
}
int min_cost_flow(int s,int t,int f)
{
    int res=0;
    fill(h,h+V,0);
    while(f>0)
    {
        priority_queue<P,vector<P>,greater<P>> que;
        fill(dist,dist+V,INF);
        dist[s]=0;
        que.push(P(0,s));
        while(!que.empty())
        {
            P p=que.top();
            que.pop();
            int v=p.second;
            if(dist[v]<p.first)
            {
                continue;
            }
            for(int i=0;i<G[v].size();++i)
            {
                edge &e=G[v][i];
                if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to])
                {
                    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                    prevv[e.to]=v;
                    preve[e.to]=i;
                    que.push(P(dist[e.to],e.to));
                }
            }
        }
        if(dist[t]==INF)
        {
            return -1;
        }
        for(int v=0;v<V;++v)
        {
            h[v]+=dist[v];
        }
        int d=f;
        for(int v=t;v!=s;v=prevv[v])
        {
            d=min(d,G[prevv[v]][preve[v]].cap);
        }
        f-=d;
        res+=d*h[t];
        for(int v=t;v!=s;v=prevv[v])
        {
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }
    return res;
}
int N,M,s,t;
int indree[520],outdree[520];
int main()
{
    scanf("%d%d",&N,&M);
    V=N+2;
    t=N+1;
    int total=0;
    for(int i=1;i<=M;++i)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        ++x,++y;
        add_edge(x,y,INF,-z);
        outdree[x]++,indree[y]++;
        total+=z;
    }
    int max_f=0;
    for(int i=1;i<=N;++i)
    {
        if(indree[i]>outdree[i])
        {
            add_edge(s,i,indree[i]-outdree[i],0);
            max_f+=indree[i]-outdree[i];
        }
        else
        {
            add_edge(i,t,outdree[i]-indree[i],0);
        }
    }
    min_cost_flow(1,N,1);
    add_edge(N,1,INF,-dist[N]);
    int ans=min_cost_flow(s,t,max_f);
    printf("%d\n",ans-total);
    return 0;
}


Measured memory_bytes: 2848
X = gets.to_i
a = Array.new
b = Array.new
a[0] = 0
b[0] = 0
for i in 1..X
    a[i] = Array.new
    for j in 2..10
        a[i][0] = 0
        a[i][1] = 0
        a[i][j] = 0
        if i ** j <= X
            a[i][j] += i ** j
        end
    end
    b[i] = a[i].max
end

puts b.max




Measured memory_bytes: 2044
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

int main() {
	int X;
	int p = 0;

	cin >> X;
	p = X;

	while (!IsPrime(p)) {
		p++;
	}

	cout << p;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#pragma warning(disable:4996)

using namespace std;

int main() {
/*    scanf("%lld", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%lld", &A[i]);
        if (A[i] <= 100) cnt[A[i]]++;
    }

    long long Answer = 0;
    for (int i = 1; i <= 50; i++) Answer += cnt[i] * cnt[101 - i];
    cout << Answer << endl;
*/
    string name;
    cin >> name;
    if (name == "ABC") { printf("ARC\n"); }
    else printf("ABC\n");
//    scanf("%d %d", &A, &B);
   
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<16,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<pair<int,int>> S(M);
    vector<int> left(N),right(N);
    for(int i=0;i<M;i++) cin>>S[i].first>>S[i].second;
    sort(all(S));
    iota(all(left),0);
    iota(all(right),0);
    
    for(int i=0;i<M;i++){
        int a=min(left[S[i].second-1],left[S[i].second]),b=max(right[S[i].second-1],right[S[i].second]);
        left[S[i].second-1]=left[S[i].second]=a;
        right[S[i].second-1]=right[S[i].second]=b;
    }
    
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<right[i]-left[i]+1;
    }
    cout<<endl;
    
    
}





Measured memory_bytes: 5212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 ll dp[2000][2000];

vector<pair<int,int>> v[101010];
P ans[101010]={};

void d(int x,int y,int last){

    if(ans[x].S>y){
        ans[x]=P(last,y);
    }
    rep(i,v[x].size()){
        if(v[x][i].S){
            v[x][i].S=1;
            d(v[x][i].F,y+1,x);
        }
    }
}

int main(){
   int n,a=0,b,h,m;
   string s;
   bool f=1;
   cin>>n>>m;
   REP(i,1,n){
       ans[i]=P(0,1010101);
   }
   
    rep(i,m){
        cin>>a>>b;
        v[a-1].pb(P(b-1,0));
        v[b-1].pb(P(a-1,0));
    }
    //d(0,0,0);
    vector<int>o;
    ll w=0;
    o.pb(0);
    ll cnt=1;
    bool f2[101010]={};
    while(o.size()-w>0){
        ll w2=w;
        ll o2=o.size();
        rep(j,o2-w){
            rep(i,v[o[w+j]].size()){
            //cout<<"fa"<<endl;
            if(ans[v[o[w+j]][i].F].S>cnt)
                ans[v[o[w+j]][i].F]=P(o[w+j],cnt);
            
            if(f2[v[o[w+j]][i].F]==0){
                f2[v[o[w+j]][i].F]=1;
                o.pb(v[o[w+j]][i].F);
                }

            }
            w2++;
        }

        cnt++;
        w=w2;
    }
    // cout<<w<<endl;
    // cout<<v[0][0].F<<endl;

    REP(i,1,n){
        if(ans[i].S==1010101){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    REP(i,1,n){
        cout<<ans[i].F+1<<endl;
    }
    
}


Measured memory_bytes: 14312
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long H, W, N;
	cin >> H >> W >> N;
	map<pair<int, int>, int>mp;
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (((x - j) >= 0) && ((y - k) >= 0) && ((x - j) <= (H - 3)) && ((y - k) <= (W - 3))) {
					pair<int, int> p = make_pair(x - j, y - k);
					mp[p]++;
				}
			}
		}
	}
	vector<long long>ans(10);
	ans[0] = (H - 2) * (W - 2) - mp.size();
	for (auto p : mp) {
		int n = p.second;
		ans[n] += 1;
	}
	for (int i = 0; i < 10; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 59780
#include <stdio.h>
int main(){
	int a,b;
	int op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '+'){
			printf("%d\n",a + b);
		}else if(op == '-'){
			printf("%d\n",a - b);
		}else if(op == '*'){
			printf("%d\n",a * b);
		}else if(op == '/'){
			printf("%d\n",a / b);
		}else{
			break;
		}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);

  for (int i=0; i<N; i++){

    cin>>vec.at(i);
  }
  int M;
  cin>>M;
  vector<string> vec2(M);

  for(int i =0; i<M; i++){
  cin>>vec2.at(i);
  }

  int x=0;

  for(int i=0; i<N; i++){
      int y=0;
      for(int j=0; j<N;j++){
          
      if(vec.at(i)==vec.at(j))
      y++;
      }
      for (int k=0; k<M; k++){
          if (vec.at(i)==vec2.at(k))
          y--;
      }
      if(x<y)
      x=y;
  }
  cout<<x<<endl;
  
}

Measured memory_bytes: 3588
# ボールの数とロボットBのx座標を定義
n = gets.chomp.to_i
k = gets.chomp.to_i

# ボールを配置するx座標を定義
ball_dir = gets.split.map(&:to_i)

# 探索
def start_calc(ball_dir, k, n)
  count_result = 0
  for i in 0...n
    count_result += calc_r_to_b_distance(ball_dir[i], k)
  end
  return count_result
end

# 各y座標上にあるボールとロボットの距離を計算する
def calc_r_to_b_distance(ball_dir, k)
  rA_to_ball = ball_dir
  rB_to_ball = k - ball_dir
  if rA_to_ball <= rB_to_ball
    count = rA_to_ball
  else
    count = rB_to_ball
  end
  return count * 2
end

# 探索結果を出力
p start_calc(ball_dir, k, n)


Measured memory_bytes: 1788
#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;
    string a;
    cin >> N >> a;
    vector<int> b;
    rep(i, N - 1) {
        b.push_back(abs(a[i] - a[i + 1]));
    }
    if (N == 2) {
        cout << b[0] << '\n';
        return 0;
    }
    /*
    rep(i, N - 1) cout << b[i];
    cout << "\n";
    */
    bool f = true;
    rep(i, N - 1) if (b[i] == 1) f = false;
    int c = 1;
    if (f) {
        rep(i, N - 1) b[i] /= 2;
        c = 2;
    }
    int ans = 0;
    rep(i, N - 1) {
        ans += (N - 2 == (i | (N - 2 - i))) * b[i];
        ans %= 2;
    }
    cout << ans * c << "\n";
}

Measured memory_bytes: 7804
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 int main()
 {
   ll int n,W,i,j;
   cin>>n>>W;
   ll int wt[n];
   ll int val[n];
   for(i=0;i<n;i++)
   {
    cin>>wt[i];
    cin>>val[i];
   }
   ll int dp[n+1][W+1];
   for(i=0;i<=W;i++)
    dp[0][i]=0;
    for(i=0;i<=n;i++)
        dp[i][0]=0;
   for(i=1;i<=n;i++)
   {
    for(j=1;j<=W;j++)
    {
        if(j>=wt[i-1])
        {
            dp[i][j]=max((dp[i-1][j-wt[i-1]]+val[i-1]),dp[i-1][j]);
        }
        else
            dp[i][j]=dp[i-1][j];
    }
   }
   cout<<dp[n][W];
 }

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

#define dump(x) cout << #x << " = " << (x) << endl
int main(){
    int l, r, a;
    const int mod = 2019;
    cin >> l >> r;

    if(l%mod==0 || r/mod-l/mod>0) cout << 0 << endl;
    else{
        l = l % mod;
        r = r % mod;
        if(r<l) swap(l,r);
        a = mod;
        for(int i=l; i<=r-1; i++){
            for(int j=i+1; j<=r; j++){
                if(((i%mod)*(j%mod))%mod < a) a = ((i%mod)*(j%mod))%mod;
            }
        }
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

using DD = double;
const DD DINF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acosl(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}

int n; 
vector<Point> p;

DD g(DD x, DD y){
	DD res = 0;
	REP(i,n){
		res = max(res, abs(p[i] - Point(x, y)));
	}
	return res;
}

DD f(DD x){
	DD low = -1000;
	DD high = 1000;

	int cnt = 500;
	while(cnt--){
		DD d = high - low;
    DD c1 = low + d / 3.0;
    DD c2 = high - d / 3.0;
		if (g(x, c1) > g(x, c2)) low = c1;
    else high = c2;
	}
	return g(x, low);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	p.resize(n);
	REP(i,n) cin >> p[i].x >> p[i].y;

	DD low = -1000;
	DD high = 1000;

	int cnt = 500;
	while(cnt--){
		DD d = high - low;
    DD c1 = low + d / 3.0;
    DD c2 = high - d / 3.0;
		if (f(c1) > f(c2)) low = c1;
    else high = c2;
	}
	cout << fixed << setprecision(10) << f(low) << '\n';
	return 0;
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
main(){
  int N,T,t_prev,sum=0;
  cin>>N>>T;
  for(int i=1;i<=N;++i){
    int t;
    cin>>t;
    if(i!=1){
      if(t-t_prev>=T){
        sum+=T;
      }else{  // t-t_prev<T
        sum+=t-t_prev;
      }
    }
    t_prev=t;
  }
  sum+=T;
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  cout << "ABC" << N << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int a[4];
    string s;
    cin>>s;
    REP(i,s.size())
    {
        a[i]=(int)(s[i]-'a');
    }
    sort(a,a+4);
    if(a[0]!=a[2]&&a[0]==a[1]&&a[2]==a[3])
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
S = input()
mojisu = len(S)
hug_a = 0
hug_b = 0
if mojisu % 2 == 0:
    for i in range(mojisu // 2):
        if S[i] != S[mojisu - (i+1)]:
            hug_a = hug_a + 1
    print(hug_a)
if mojisu % 2 == 1:
    for j in range((mojisu-1) // 2):
        if S[j] != S[mojisu - (j+1)]:
            hug_b = hug_b + 1
    print(hug_b)

Measured memory_bytes: 3064
import java.util.*;

class Main{

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

        while(true){
            int x = sc.nextInt();
            int h = sc.nextInt();
            if(x==0 && h==0) break;
            double hyou = x*Math.sqrt(4*h*h+x*x) + x*x;
            System.out.println(hyou);
        }
    }
}

Measured memory_bytes: 17156
#import <stdio.h>
typedef long long INT;

int main() {
    INT N;
    scanf("%lld",&N);
    INT O = 0;
    for (INT i=0;i<N;i++) {
        INT a;
        scanf("%lld", &a);
        if (a%2==1) {
            O++;
        }
    }
    printf(O%2==0?"YES":"NO");
}


Measured memory_bytes: 7504
import sys

H,W,A,B = map(int,input().split())

if H//2 < B or W//2 < A:
    print("No")
    sys.exit()

ans1 = ''
ans2 = ''
for i in range(W):
    if i < A:
        ans1 = ans1 + '1'
        ans2 = ans2 + '0'
    else:
        ans1 = ans1 + '0'
        ans2 = ans2 + '1'

for _ in range(B):print(ans1)
for _ in range(H-B):print(ans2)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std ;
int main()
{  int k;
cin>>k;
    int a[]={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};
    cout<<a[k-1]<<endl;
}

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

#define   INF 1<<21
#define MAX_V 100

int n,m;

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

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

int dfs(int v, int t, int f);

int main(){
  
  cin>>n>>m;
  int from,to,cap;
  for(int i=0;i<m;i++){
    cin>>from>>to>>cap;
    add_edge(from,to,cap);
  }

  int s=0,t=n-1;
  int flow=0;
  while(1){
    memset(used,0,sizeof(used));
    int f=dfs(s, t, INF);
    if(f == 0){
      cout<<flow<<endl;
      return(0);
    }
    flow+=f;
  }

  return(0);
}



int dfs(int v, int t, int f){
  // cout<<v<<" "<<t<<" "<<f<<endl;
  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){
      int 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);
}

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

int main()

{
    int a,b,c,i,j,m,n;

    char s[10];

    scanf("%d",&a);

    scanf("%s",&s);

    if(a<3200){

        printf("red\n");

       // printf("a = %d is less than 3200,so we print red.",a);

    }

    else{

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

       // printf("a = %d is not less than 3200,so we print s = %s.",a,s);
    }

    return 0;
}

Measured memory_bytes: 256
def main(H, W):
    if H == 1 or W == 1:
        return 1
    od = -(-W // 2)
    ev = W // 2
    ans = (od + ev) * (H // 2)
    if H % 2 == 1:
        ans += od
    return ans


if __name__ == "__main__":
    H, W = map(int, input().split())
    ans = main(H, W)
    print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] color = new int[H][W];
        int[] HH = new int[H];
        int[] WW = new int[W];
        String[] c = new String[H];
        String stush = sc.nextLine();
        for (int i = 0; i < H; i++) {
            c[i] = sc.nextLine();
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (c[i].charAt(j) == '.') {
                    color[i][j] = 0;
                } else {
                    color[i][j] = 1;
                }
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                HH[i] += color[i][j];
            }
        }
        // ok
        for (int j = 0; j < W; j++) {
            for (int i = 0; i < H; i++) {
                WW[j] += color[i][j];
            }
        }
        int ansH = 0;
        for (int i = 0; i < H; i++) {
            if (HH[i] != 0) {
                ansH++;
            }
        }
        int ansW = 0;
        for (int j = 0; j < W; j++) {
            if (WW[j] != 0) {
                ansW++;
            }
        }
        // ok
        int[][] answer = new int[ansH][W];
        int insertH = 0;

        for (int j = 0; j < H; j++) {
            if (HH[j] != 0) {
                for (int k = 0; k < W; k++) {
                    answer[insertH][k] = color[j][k];
                }
                insertH++;
            }
        }

        int[][] answer2 = new int[ansH][ansW];
        int insertW = 0;
        for (int j = 0; j < W; j++) {
            if (WW[j] != 0) {
                for (int k = 0; k < ansH; k++) {
                    answer2[k][insertW] = answer[k][j];
                }
                insertW++;
            }
        }

        for (int i = 0; i < ansH; i++) {
            for (int j = 0; j < ansW; j++) {
                if (answer2[i][j] == 0) {
                    System.out.print(".");
                } else {
                    System.out.print("#");
                }
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 26324
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;cin>>x>>y;
  if(y%2==1)cout<<"No"<<endl;
  else if(y<2*x||y>4*x)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3648
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, m = map(int, input().split())
data = getInputListInt()

data.sort()

disdata = []
for i in range(m-1):
    disdata.append(data[i+1] - data[i])

disdata.sort(reverse=True)

ans = 0
for i in range(n-1, m-1):
    ans += disdata[i]

print(ans)


Measured memory_bytes: 23856
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 102
//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
vector<int > A;
void solve(){
	sort(A.begin(), A.end());
	ans = A[N-1]-A[0];
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int b;
		cin >> b;
		A.push_back(b);
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.array, std.conv, std.string, std.math, std.container, std.typecons;

void main() {
    auto S = readln.split.to!(int[]);
    auto H = S[0], W = S[1];
    char[][] cell;
    foreach (y; 0..H) {
        cell ~= readln.to!(char[]);
    }
    auto white = cell.map!(c => c.count('.')).sum;
    DList!(Tuple!(int, int,int)) queue;
    long score = long.max;
    queue.insertBack(tuple(0,0,1));
    while (!queue.empty) {
        auto x = queue.front[0];
        auto y = queue.front[1];
        auto s = queue.front[2];
        queue.removeFront();
        if (x == W-1 && y == H-1) {
            score = min(score, s);
            continue;
        }
        if (x < 0) continue;
        if (y < 0) continue;
        if (x >= W) continue;
        if (y >= H) continue;
        if (cell[y][x] == '#') continue;
        cell[y][x] = '#';
        queue.insertBack(tuple(x-1,y,s+1));
        queue.insertBack(tuple(x+1,y,s+1));
        queue.insertBack(tuple(x,y-1,s+1));
        queue.insertBack(tuple(x,y+1,s+1));
    }
    if (score == long.max) {
        writeln(-1);
        return;
    }
    writeln(white - score);
}



Measured memory_bytes: 636
#include<iostream>
#include<iomanip>
#include<cmath>

double sqr( double x )
{
	return x * x;
}

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

	while( n-- )
	{
		double x1, y1, x2, y2, x3, y3;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double a = x1 - x2, b = y1 - y2, c = -( sqr( x1 ) + sqr( y1 ) ) + ( sqr( x2 ) + sqr( y2 ) ),
			   d = x2 - x3, e = y2 - y3, f = -( sqr( x2 ) + sqr( y2 ) ) + ( sqr( x3 ) + sqr( y3 ) );

		double l = ( c * e - b * f ) / ( e * a - b * d ), m = ( c * d - a * f ) / ( b * d - a * e );
		double n = -( sqr( x1 ) + sqr( y1 ) + l * x1 + m * y1 );

		std::cout << std::fixed << std::setprecision( 3 );
		std::cout << -l / 2.0 << " " << -m / 2.0 << " " << sqrt( sqr( l ) + sqr( m ) - 4 * n ) / 2.0 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  rep(i, N) cin >> T[i];
  sort(all(T));
  int ans = 1, start = T[0], pas = 1;
  REP(i, 1, N){
    if(T[i] <= start + K && pas + 1 <= C){
      pas++;
    }else{
      //cerr << i << ": " << T[i] << endl;
      start = T[i];
      pas = 1;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}
string n;
int main(){
  cin >> n;
  int size = n.size()-1;
  if(n[size]=='3')cout<< "bon" <<endl;
  else if(n[size]=='0' || n[size]=='1' || n[size]=='6' || n[size]=='8')cout<< "pon" <<endl;
  else cout<< "hon" <<endl;
}


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

typedef vector <int> VI;

int check( double s )
{
	if ( s >= 1.1 ) return 0;
	else if ( s >= 0.6 ) return 1;
	else if ( s >= 0.2 ) return 2;
	else if ( s < 0.2 ) return 3;
	return 4;
}

int main( void )
{
	VI lefts(5,0), rights(5,0);
	double left, right;
	while ( cin >> left >> right )
	{
		int l = check( left );
		lefts[l]++;
		int r = check( right );
		rights[r]++;
	}
	for ( int i = 0; i < 4; i++ ) cout << lefts[i] << " " << rights[i] << endl;
	return 0;
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 200100
#define MOD 998244353

using namespace std;

long long n, k, sum, dp[DMAX][5][5], dp2[DMAX], ans;

string s;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

bool same() {
	for(long long i = 1; i < n; i++) 
		if(s[i] != s[i - 1])
			return 0;
	return 1;
}
bool dif() {
	for(long long i = 1; i < n; i++) 
		if(s[i] == s[i - 1])
			return 0;
	return 1;
}

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

	cin >> s;
	n = s.size();
	if(same()) {
		cout << 1 << '\n';
		return 0;
	}
	if(s.size() == 2)	{
		cout << 2 << '\n';
		return 0;
	}
	if(s.size() == 3) {
		if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0])
			cout << 3 << '\n';
		else if(s[0] == s[2]) cout << 7 << '\n';
		else cout << 6 << '\n';
		return 0;
	}

	for(long long i = 0; i < n; i++) sum += (s[i] - 'a');
	sum %= 3;

	dp[1][0][0] = 1;
	dp[1][1][1] = 1;
	dp[1][2][2] = 1;

	for(long long i = 2; i <= n; i++)
		for(long long j = 0; j < 3 ; j++)
			for(long long k = 0; k < 3; k++)
				for(long long kk = 0; kk < 3; kk++)
					if(kk != k)
						dp[i][j][k] += (dp[i - 1][(3 + j - k) % 3][kk]) % MOD;


	dp2[1] = 1;

	for(long long i = 2; i <= n; i++) {
		dp2[i] = (dp2[i - 1] * 3) % MOD;
	}

	ans = ((dp2[n] - dp[n][sum][0] - dp[n][sum][1] - dp[n][sum][2]) % MOD + MOD) % MOD;
	cout << ans + dif() << '\n';
	// cout << (dp2[n] - dp[n][sum][0] - dp[n][sum][1] - dp[n][sum][2]) << '\n';
}

Measured memory_bytes: 41236
'''AtCoder水色になりたいのよさ
一番左を「1」にするために、「num」の初期値を1にし、
配列aを順番に判定していきます。
1以外のブロックは壊して「b_num」に足していきます。
1が見つかった後は、「num」を1増やして、同じ処理を続けます。
結果的に壊したブロックの数「b_num」が答えになります。
'''
n = int(input())
a = list(map(int, input().split()))
num = 1
b_num = 0

for i in range(n):
    if num != a[i]:
        b_num += 1
    else:
        num += 1

if b_num == n:
    b_num = -1

print(b_num)

Measured memory_bytes: 26140
# ABC148D - Brick Break
def main():
    N, *A = map(int, open(0).read().split())
    remaining = 0
    cur = 0  # current index
    for target in range(1, N + 1):
        be_kept = False
        for i in range(cur, N):
            if A[i] == target:
                remaining += 1
                cur = i + 1
                be_kept = True
                break
        if not be_kept:
            break
    print(N - remaining if remaining else -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25116
strSlopeFlat = list(input())

stack_total = []
starck_areas = []

for i,x in enumerate(strSlopeFlat):
    if x == '\\':
        stack_total.append(i)
    elif x == '/' :
        onearea = 0
        if len(stack_total) > 0:
            pos = stack_total.pop()
            onearea = (i-pos)
            while len(starck_areas)>0 and starck_areas[-1][0] > pos:
                tmp_pop = starck_areas.pop()
                onearea += tmp_pop[1]
            starck_areas.append([pos,onearea])

print(sum([y for x,y in starck_areas]))
results = [x[1]  for x in starck_areas if x[1] != 0]
print(len(results),*results)

Measured memory_bytes: 8404
#include<iostream>
#include<vector>
using namespace std;
class union_find{
private:
    vector<int>parent;
    vector<int>rank;
    int cnt;
public:
    union_find(int vertex_num)
    {
        parent.resize(vertex_num);
        rank.resize(vertex_num);
        for(int i = 0; i < vertex_num; ++i){
            parent[i] = i;
            rank[i] = 0;
        }
        cnt = vertex_num;
    }
    int get_root(int n)
    {
        if(parent[n] == n){
            return n;
        }else{
            return get_root(parent[n]);
        }
    }
    bool is_same(int a, int b)
    {
        return get_root(a) == get_root(b);
    }
    void unite(int a, int b)
    {
        int root_a=get_root(a),root_b=get_root(b);
        if(root_a == root_b)return;
        if(rank[root_a] < rank[root_b]){
            parent[root_a] = root_b;
            --cnt;
        }else if(rank[root_a] > rank[root_b]){
            parent[root_b] = root_a;
            --cnt;
        }else{
            parent[root_a] = get_root(root_b);
            ++rank[root_b];
            --cnt;
        }
    }
    bool is_all_connected()
    {
        return cnt == 1;
    }
};
int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>>ab(m);
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        ab[i] = make_pair(a, b);
    }

    int ans = 0;
    for(int i = 0; i < m; ++i){
        union_find uf(n);
        for(int j = 0; j < m; ++j){
            if(i == j)continue;
            uf.unite(ab[j].first, ab[j].second);
        }
        if(!uf.is_all_connected()){
            ++ans;
        }
    }
    cout << ans << endl;
}


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

int main() {

  int N ; cin >> N ;
  int S ; S = 0 ;

  for (int i = 0 ; i < N ; i++ ){
    int l, r ; cin >> l >> r ;
      S += r - (l - 1);
  }
  cout << S << endl;
}


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

struct dice {
    int v[6];
    void mov(const char c) {
        int buf;
        switch (c) {
            case 'N':
                buf = v[0];
                v[0] = v[1];
                v[1] = v[5];
                v[5] = v[4];
                v[4] = buf;
                break;
            case 'E': {
                buf = v[0];
                v[0] = v[3];
                v[3] = v[5];
                v[5] = v[2];
                v[2] = buf;
                break;
            }
            case 'W': {
                buf = v[0];
                v[0] = v[2];
                v[2] = v[5];
                v[5] = v[3];
                v[3] = buf;
                break;
            }
            case 'S': {
                buf = v[0];
                v[0] = v[4];
                v[4] = v[5];
                v[5] = v[1];
                v[1] = buf;
                break;
            }
        }
    }
    int top() { return v[0]; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    dice d;
    int in[6];
    for (int i = 0; i < 6; i++) {
        cin >> d.v[i];
    }
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        d.mov(s[i]);
    }
    cout << d.top() << endl;
    return 0;
}


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

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new long[n];
            var r = ReadSplit();
            var mCount = 0;
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                l[i] = Math.Abs(r[i].Long());
                if (r[i].Long() < 0) mCount++;
                ans += Math.Abs(l[i]);
            }
            if (mCount % 2 != 0)
            {
                ans -= l.Min() * 2;
            }
            WriteRead(ans);
        }
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 27228
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
carry = 0
for i in range(n):
  if carry >= a[i]:
    carry = b[i]
    ans += a[i]
  elif carry + b[i] >= a[i]:
    carry = carry + b[i] - a[i]
    ans += a[i]
  else:
    ans += carry + b[i]
    carry = 0
ans += min(a[n], carry)
print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{ 
	ll n,m;
	cin>>n>>m;
	ll arr[n];
	REP(i,0,n){
		cin>>arr[i];
	}
	vector<ll> edges[n];
	REP(i,0,m){
		ll x,y;
		cin>>x>>y;
		edges[x-1].push_back(y-1);
		edges[y-1].push_back(x-1);
	}
	ll ct = n;
	REP(i,0,n){
		ll h = arr[i];
		bool f = 0;
		for(auto it:edges[i]){
			if(h <= arr[it]){
				f = 1;
				break;
			}
		}
		if(f == 1) ct--;
	}
	cout<<ct<<endl;
	return 0;	
}  


Measured memory_bytes: 10252
from collections import deque
N, K, L = map(int, input().split())
roads = [[] for _ in range(N)]
rails = [[] for _ in range(N)]
group = [[-1, -1, i] for i in range(N)]
for i in range(K):
    p, q = map(int, input().split())
    roads[p-1].append(q-1)
    roads[q-1].append(p-1)
for i in range(L):
    p, q = map(int, input().split())
    rails[p-1].append(q-1)
    rails[q-1].append(p-1)
def BFS(v0, List, i):
    que = deque([v0])
    while que:
        v = que.pop()
        group[v][i] = v0
        for e in List[v]:
            if group[e][i]<0:
                que.append(e)
for v in range(N):
    if group[v][0]<0:
        BFS(v, roads, 0)
    if group[v][1]<0:
        BFS(v, rails, 1)
group.sort()
ans = [0]*N
cnt = 1
start = 0
for i in range(N-1):
    if group[i][:2] == group[i+1][:2]:
        cnt+=1
    else:
        for j in range(start, i+1):
            c = group[j][2]
            ans[c] = cnt
        cnt = 1
        start = i+1
for j in range(start, N):
    c = group[j][2]
    ans[c] = cnt
print(*ans)        
                

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

int main(){

    int N;
    cin >> N;

    vector<int> W(N);
    for(int i=0; i<N; i++){
        cin >> W.at(i);
    }

    int m=1000000;
    for(int T=0; T<N; T++){
        int S1=0, S2=0;
        for(int j=0; j<N; j++){
            if(j<=T) S1+=W.at(j);
            if(j>T) S2+=W.at(j);
        }
        int difference = S1-S2;
        if(difference<0) difference = -difference;

        m = min(m, difference);
    }

    cout << m << endl;




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long int c[100001];
long int cost(int a[],int i,int k){
    if(i==0)return 0;
    //if(i==1)return abs(a[1]-a[0]);
    if(c[i]!=-1)return c[i];
    long int min1=10000000001;
    for(int j = 1;j<=k;j++){
        if(i<j)break;
        min1= min(min1,cost(a,i-j,k)+abs(a[i]-a[i-j]));
    }
    c[i]=min1;
    return c[i];
    //return c[i]= min(cost(a,i-1)+abs(a[i]-a[i-1]),cost(a,i-2)+abs(a[i]-a[i-2]));
 }
int main(){
    int n,k;
    cin >>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[i]=-1;
    }
    cout << cost(a,n-1,k)<<endl;
    
    // for(int i=0;i<n;i++){
    //     cout<<c[i]<<endl;
    // }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int m=n, count=0;
  while(m>0){
    count += m%10;
    m /= 10;
  }
  if(n%count == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll n,d,ans=0;
    cin>>n>>d;
    FOR(i,0,n)
    {
    	ll x,y;
    	cin>>x>>y;
    	if(x*x+y*y<=d*d){ans++;}
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define X 1000010
ll fac[X],ivf[X],inv[X];
ll C(ll n,ll k){
	if(n<k)return 0;
	if(k<0)return 0;
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
void init(){
	fac[0]=ivf[0]=inv[1]=1;
	for(ll i=1;i<X;i++){
		if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
		fac[i]=fac[i-1]*i%mod;
		ivf[i]=ivf[i-1]*inv[i]%mod;
	}
}
ll f[X];
int main(){
	init();
	ll n;
	cin>>n;
	for(int k=1;k<=n-1;k++){
		if(n-1-k>=0){
			f[k]=C(k-1,n-k-1)*fac[k]%mod*fac[n-1-k]%mod;
		}
	}
	for(int k=n-1;k>=2;k--){
		f[k]-=f[k-1];
	}
	ll ans=0;
	for(int k=1;k<=n-1;k++){
		ans=(ans+f[k]*k)%mod;
	}
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
}





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

int l,r,a=10000000;

int main(){
    cin>>l>>r;
    if(r-l>2019){
        cout<<0<<endl;
        return 0;
    }
    l%=2019;
    r%=2019;
    if(l>r){
        cout<<0<<endl;
    }
    else{
        for(int i=l;i<r;i++){
            for(int j=i+1;j<=r;j++){
                a=min(a,i*j%2019);
            }
        }
        cout<<a<<endl;
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin>>N;
	
	LL n = N;
	LL p = 0;
	while (n) {
		p += n % 10;
		n/= 10;
	}
	
	cout<<(N%p==0?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256