akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 110;

int dp[N][5][2];
  int n ;
  string s;
int solve(int id,int k,int f){
  if(k<0)return 0;
  if(id<0){
    if(k==0)return 1;
    return 0;
  }
  int &x = dp[id][k][f];
  if(x!=-1)return x;
  x=0;
  for(int i=0;i<10;i++){
    // coloca i aqui:
    if(i > s[id]-'0' and f==0)continue;
    int nf = f;
    if(i<s[id]-'0')nf=1;
    x+=solve(id-1,k-(i!=0?1:0),nf);
  }
  return x;
}

int32_t main(){
  fastio;
  cin>>s;
  reverse(s.begin(),s.end());
  int k;
  cin>>k;
  memset(dp,-1,sizeof(dp));
  n = s.size();
  cout << solve(n-1,k,0) << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll pow(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--){
    	ll n,m,i,j;
    	cin>>n>>m;
    	ll sum=0;
    	ll a[m+1];
    	for(i=0;i<m;i++)
    	{
    		cin>>a[i];
    		sum+=a[i];
		}
		if(sum>n)
		cout<<-1;
		else
		{
			cout<<n-sum;
		}
    }}
    	

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

using namespace std;

int n,u,v;
vector<int> AdjList[100001];
int mark[100001];

int z;

bool dfs_1(int a,int p,int k)
{
	if (z - k >= mark[a])
		return false;
	if (k % 2 == 0 && mark[a] == 1e9)
		for (int i=0;i<AdjList[a].size();i++)
		{
			int b = AdjList[a][i];
			if (mark[b] == 1e9)
				return true;
		}
	if (k == 0)
		return false;	
	for (int i=0;i<AdjList[a].size();i++)
	{
		int b = AdjList[a][i];
		if (b != p)
			if (dfs_1(b,a,k-1))
				return true;
	} 
	return false;
}

void dfs_2(int a,int p,int k)
{
	mark[a] = z - 1 - k;
	if (!k)
		return;
	for (int i=0;i<AdjList[a].size();i++)
	{
		int b = AdjList[a][i];
		if (b != p)
			dfs_2(b,a,k-1);
	}
}

bool check(int x)
{
	z = x;
	for (int i=1;i<=100000;i++)
		mark[i] = 1e9;
	dfs_2(v,-1,x-1);
	if (dfs_1(u,-1,x))
		return true;
	return false;
}

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

	cin >> n >> u >> v;
	for (int i=1;i<=n-1;i++)
	{
		int a,b;
		cin >> a >> b;
		AdjList[a].push_back(b);
		AdjList[b].push_back(a);
	}
	int l = 1, r = n;
	int ans = 0;
	while(l <= r)
	{	
		int mi = (l+r)/2;
		if (check(mi))
			l = mi + 1;
		else
		{
			ans = mi - 1;
			r = mi - 1;
		}	
	}
	cout << ans;
}

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

main() {
    int N; cin >> N; int pos=0; int ans=0;
    rep(i,N){
        int p; cin >> p;
        pos=max(pos,p);
        ans+=p;
    }
    cout << ans - pos/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;
void solve(){
  int n; cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  int on = 0, tn = 0;
  for(auto it = mp.begin(); it != mp.end(); it++){
    if(it->second % 2 == 0) tn++;
    else on++;
  }
  int ans = mp.size();
  if(tn % 2 == 1) ans--;
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int,int>P;
int main(){
  int n;
  P array[200005];
  cin>>n;
  for(int i=0;i<n;i++){
    int times,deadline;
    cin>>times>>deadline;
    array[i]=P(deadline,times);
  }
  sort(array,array+n);
  
  int sum=0;
  bool is_finished=true;
  for(int i=0;i<n;i++){
    sum+=array[i].second;
    if(sum>array[i].first){
      is_finished=false;
    }
  }
  
  if(is_finished){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

constexpr int INF = 1e9;

class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) { // size(x) > size(y)
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par_[root(x)];
    }

private:
    std::vector<int> par_;
};


struct edge {
    int s, t;
    int cost;
    bool operator<(edge const& e) const {
        return cost < e.cost;
    }
};

using edges = vector<edge>;
using graph = vector<edges>;

edges kruskal (int V, edges& es) {
    sort(es.begin(), es.end());
    union_find uf(V);
    edges res;
    for(int i=0; i<es.size(); ++i) {
        edge e = es[i];
        if(!uf.same(e.s, e.t)) {
            uf.unite(e.s, e.t);
            res.push_back(e);
        }
    }
    return res;
}

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        edges es(m);
        for(int i=0; i<m; ++i) {
            cin >> es[i].s >> es[i].t >> es[i].cost;
            es[i].s--;
            es[i].t--;
        }
        auto res = kruskal(n, es);
        cout << res[n/2-1].cost << endl;
    }
}


Measured memory_bytes: 3148
#include <cstdio>
#include <algorithm>
using namespace std;

#define INF 0x7fffffff

int n;
int dp[100001];

int main() {
    scanf("%d", &n);
    fill(dp, dp+n, INF);
    for (int i=0; i<n; i++) {
        int a;

        scanf("%d", &a);
        *lower_bound(dp, dp+n, a) = a;
    }

    printf("%ld\n", lower_bound(dp, dp+n, INF) - dp);
}

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

int main(){
  int m,n;
  int cx[200],cy[200],sx[1000],sy[1000];
  int x,y;
  bool flag,flag2;

  while(1){
    cin >> n;
    if(!n)break;
    
    for(int i=0;i<n;i++)cin >> cx[i] >> cy[i];
    cin >> m;
    for(int i=0;i<m;i++)cin >> sx[i] >> sy[i];
    
    for(int i=0;i<m;i++){
      x = sx[i] - cx[0];
      y = sy[i] - cy[0];
      flag = true;
      for(int j=1;j<n;j++){
	flag2 = false;
	for(int k=0;k<m;k++){
	  if(sx[k] == cx[j] + x && sy[k] == cy[j] + y){
	    flag2 = true;
	    break;
	  }
	}
	if(!flag2){
	  flag = false;
	  break;
	}
      }
      if(flag){
	cout << x << " " << y << endl;
	break;
      }
    }
  }
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

struct DSU{
    int SZ;
    vector<int> p, r, s;
    DSU(int sz): SZ(sz){
        p.assign(SZ, 0);
        iota(p.begin(), p.end(), 0);
        r.assign(SZ, 0);
        s.assign(SZ, 1);
    }
    int find(int u){
        if(p[u] != u) p[u] = find(p[u]);
        return p[u];
    }
    void merge(int u, int v){
        u = find(u); v = find(v);
        if(u == v) return;
        if(r[u] < r[v]) swap(u, v);
        r[u]++, s[u] += s[v], p[v] = u;
    }
};

int n, m;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    DSU tree(n);
    for(int i = 0; i < m; ++i){
        int a, b; cin >> a >> b;
        a--, b--; tree.merge(a, b);
    }   
    int res = 0; 
    for(int i = 0; i < n; ++i){
        ckmax(res, tree.s[i]);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(true){
		int k;	cin>>k;
		if(k==0)	return 0;
		int n=k*(k-1)/2;
		int sum=0;
		for(int i=0;i<n;i++){
			int c;	cin>>c;
			sum+=c;
		}
		cout<<sum/(k-1)<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

int n = 1e5+100;
vector<vi> g(n);
map<ll, int> ans;

ll f(int a, int b) {
  if (b > a) swap(a, b);
  return a*1e7+b;
}

void dfs(int i, int pre, int c) {
  ans[f(i, pre)] = c;
//cerr << "c" << ans[f(i, pre)] << endl;
  int cnt = 1;
//  cerr << i << endl;
//  cerr << endl;
//  cerr << "si" << g[i].size() << endl;
  for (auto&& j : g[i]) {
    if (j != pre) {
      if (cnt == c) cnt++;
//      cerr << j << " " << i << " " << cnt << endl;
      dfs(j, i, cnt);
      cnt++;
    }
  }
}

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

  int n;
  cin >> n;
  vector<pii> e(n-1);
  vi degree(n);
  rep(i, n-1) {
    cin >> e[i].first >> e[i].second;
    e[i].first--;
    e[i].second--;
    degree[e[i].first]++;
    degree[e[i].second]++;

    g[e[i].first].push_back(e[i].second);
    g[e[i].second].push_back(e[i].first);
  }

  int k = 0;
  rep(i, n) {
    cmax(k, degree[i]);
  }

  dfs(0, -1, -1);

  cout << k << endl;
  rep(i, n-1) {
    cout << ans[f(e[i].first, e[i].second)] << endl;
  }
}


Measured memory_bytes: 15232
#include<stdio.h>

int main()
{
  int i,n,sosu=0,x,j,ans;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%d",&x);
      ans=0;
      
      for(j=2;j*j<=x;j++)
	{
	  
	  if( (x%j)==0 )
	    {
	      ans++;
	      break;
	    }
	}
      if(ans==0)sosu++;
    }

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

  return 0;
}



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

const char w[] = {'A', 'C', 'G', 'T'};

int main() {
    string S;
    cin >> S;
    int p = 0;
    string ans = "";
    for (int i = 0; i < S.size(); i++) {
        string tmp = "";
        while(S[i]==w[0]||S[i]==w[1]||S[i]==w[2]||S[i]==w[3]){
            tmp += S[i];
            i++;
        }
        if(tmp.size()>ans.size()){
            ans = tmp;
        }
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL  long long
#define LIM 21
#define MOD 1000000007


int n, last, ara[LIM][LIM], dp[LIM][1<<LIM];
bool vis[LIM][1<<LIM];
bool chkBit(int val, int pos){return val&(1<<pos);}
int setBit(int val, int pos){return val|(1<<pos);}

LL f(int b, int mask){
    if(mask == last) return 1LL;
    if(vis[b][mask]) return dp[b][mask];
    vis[b][mask] = 1;
    LL ans = 0;
    for(int i = 0; i < n; i++){
        if(ara[b][i] && !chkBit(mask, i)){
            LL cur = f(b+1, setBit(mask, i));
            //cout<<"cur = "<<cur<<'\n';
            ans = (ans + cur)% MOD;
        }
    }
    return dp[b][mask] = ans;
}

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d", &n);
    last = (1<<n) - 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) scanf("%d", &ara[i][j]);
    }
    LL ways = f(0, 0);
    printf("%lld\n", ways);
}




Measured memory_bytes: 120140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  set<int> s1;
  int l,r,k;
  cin>>l>>r>>k;
  rep(i,l,min(l+k,r)) s1.insert(i);
  rrep(i,r,max(r-k+1,l)) s1.insert(i);
  for(auto i:s1){
    cout<<i<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def generatePrimes(n):
    if n < 2:
        return []
    isPrimeArray = [True] * (n + 1)
    isPrimeArray[0], isPrimeArray[1] = False, False
    for i in range(2, n+1):
        if isPrimeArray[i]:
            k = 2 * i
            while k < n + 1:
                isPrimeArray[k] = False
                k += i
    return list(filter(lambda i: isPrimeArray[i], range(n+1)))


def main():
    N = II()
    if N <= 1:
        print(0)
        exit()
    max_prime = math.ceil(N**0.5)
    primes = generatePrimes(max_prime)
    es = [0] * len(primes)
    for i in range(len(primes)):
        while N % primes[i] == 0:
            N /= primes[i]
            es[i] += 1

    ans = 0
    if int(N) != 1:
        ans += 1

    for i in range(len(es)):
        k = 1
        while es[i] - k >= 0:
            es[i] -= k
            k += 1
            ans += 1

    print(ans)


main()


Measured memory_bytes: 81868
#include <bits/stdc++.h>
using namespace std;
const int MAX_NM=33,MAX_TP=21;

int n,m,t,p,ans;
int d[MAX_TP],c[MAX_TP],x[MAX_TP],y[MAX_TP];
pair<int,int> pos[MAX_NM][MAX_NM];

void solve(){
    for (int i=0;i<n;++i)
        for (int j=0;j<m;++j)
            pos[i][j]={i,j};
    for (int k=0;k<t;++k){
        if (d[k]==1){
            for (int i=0;i<n;++i){
                for (int j=0;j<m;++j){
                    if (pos[i][j].first<c[k]){
                        pos[i][j].first=c[k]-pos[i][j].first-1;
                    } else pos[i][j].first-=c[k];
                }
            }
        } else {
            for (int i=0;i<n;++i){
                for (int j=0;j<m;++j){
                    if (pos[i][j].second<c[k]){
                        pos[i][j].second=c[k]-pos[i][j].second-1;
                    } else pos[i][j].second-=c[k];
                }
            }
        }
    }
    for (int k=0;k<p;++k){
        ans=0;
        for (int i=0;i<n;++i)
            for (int j=0;j<m;++j)
                ans+=(pos[i][j]==make_pair(x[k],y[k]));
        cout << ans << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m >> t >> p,n){
        for (int i=0;i<t;++i) cin >> d[i] >> c[i];
        for (int i=0;i<p;++i) cin >> x[i] >> y[i];
        solve();
    }
}


Measured memory_bytes: 3160
n,t = gets.split.map(&:to_i)
list = (1..n).map{gets.split.map(&:to_i)}.sort
tm = t-1
dp = [0]*(t)
ans = 0
list.each{|a,b|
  if ans < tmpans=dp[tm]+b
    ans = tmpans
  end
  (t-1-a).downto(0){|ti|
    if dp[tia=ti+a] < dpb=dp[ti]+b
      dp[tia] = dpb
    end
  }
}
p ans

Measured memory_bytes: 2296
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  vector<int> d(n);
  rep (i, n) cin >> d[i];
  sort(d.begin(), d.end());

  int count = 0;
  rep (i, n) {
      if (i != 0)
      {
          if (d[i] == d[i-1])
          {
              /* code */
              continue;
          }
      }
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int a, b, c;
int main() {
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

threshold_volume = a * a * b / 2

if x > threshold_volume:
    remainder_volume = a * a * b - x
    length = 2 * remainder_volume / a ** 2
    print(math.degrees(math.atan(length / a)))
else:
    length = 2 * x / (a * b)
    print(math.degrees(math.atan(b / length)))



Measured memory_bytes: 3060
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ

int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

vector<int> divisor(int n){  //  約数列挙 O(√n)
Vi r;for(int i=1;i*i<=n;i++){if(n%i==0){r.pb(i);if(i*i!=n)r.pb(n/i);}}sort(ALL(r));return r;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  if(n==1||n==2) {cout<<0<<endl;return 0;}
  Vi a = divisor(n);
  
  int ans = 0;
  rep(i,0,n){
    if(n/a[i] - 1 > a[i]) ans += n/a[i] - 1;
    else break;
  }
  cout <<ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  if ((a - b) % 2 == 0)
  {
    cout << min({b - 1, n - a, (b - a) / 2}) << endl;
  }
  else
  {
    cout << min({b - 1, n - a, (b + a - 1) / 2, n - (b + a - 1) / 2}) << endl;
  }

  return 0;
}


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

using namespace std;

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

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

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

const long long MOD = 1000000007;

long long f(vector<long long> a) {
    int ans = 0;
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[i]) ans++;
        }
    }
    return ans;
}

void solve(long long N, long long K, std::vector<long long> A) {
    auto xxx = [&](int i) {
        vector<long long> w;
        for (int j = 0; j < i; j++) {
            w.insert(w.end(), A.begin(), A.end());
        }
        return f(w);
    };

    long long d = xxx(2) - 2 * xxx(1);

    auto yyy = [d, xxx](long long K) {
        return ((K * (K - 1) / 2) % MOD * d + xxx(1) * K % MOD) % MOD;
    };

    cout << yyy(K) << endl;
}

/*
long long ans = 0;
int pr = 0;
auto xxx = [&](int i) {
    vector<long long> w;
    for (int j = 0; j < i; j++) {
        w.insert(w.end(), A.begin(), A.end());
    }
    return f(w);
};
long long d = xxx(2) - 2 * xxx(1);
cout << d << endl;
cout << ((K * (K - 1) / 2) % MOD * d + xxx(1) * K % MOD) % MOD << endl;

}
 */

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N - 1 - 0 + 1);
    for (int i = 0; i < N - 1 - 0 + 1; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 384
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int A, B, T;

	std::cin >> A >> B >> T;

	std::cout << (std::max(T / A, 0) * B) << "\n";
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
data = []
ans = -1
value = 1
for i in range(n):
  if a[i] == value:
    data.append(value)
    value += 1
  #print(value)
#print(data)
if len(a) - len(data) == len(a):
  print('-1')
else:
  print(len(a) - len(data))

Measured memory_bytes: 24744
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
p = map(lambda x: sum(range(1,x+1))/x, p)
 
l = [0]
for i,v in enumerate(p):
    prev = l.pop()
    l.append(prev)
    l.append(prev + v)
 
ans = 0
for i in range(k, len(l)):
    tmp = l[i] - l[i-k]
    if ans < tmp:
        ans = tmp
 
print(ans)

Measured memory_bytes: 81760
S = list(input())
Alphabet_list = set(S)
mincnt = 10**5

for letter in Alphabet_list:
    #convert T->Uniform
    cnt = 0
    T = S.copy()
    while(len(set(T)) > 1):
        cnt += 1
        for i in range(len(T)-1):
            if(T[i] == letter or T[i+1] == letter):
                T[i] = letter
            else:
                pass
        del T[-1]
    mincnt = min(mincnt,cnt)
print(mincnt)



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

int main(){
  int A;
  int B;
  cin >> A >> B;

  int ans = 0;
  if(A<=9 && B<=9){
    ans = A*B;
  }else{
    ans = -1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if(a*n<b)
		printf("%d",a*n);
	else
		printf("%d",b);
	return 0;
}


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

int main()
{
	int K,N;
	cin >> K >> N;
	rep(i,N)
	{
		cin >> A[i];
	}
	int temp = A[0] + K - A[N-1];
	rep(i,N-1)
	{
		temp = max(temp,A[i+1] - A[i]);
	}
	cout << K - temp << endl;
	return 0;
}

Measured memory_bytes: 1024
c = []
for i in range(0,3):
    sub  = str(input()).split()
    c.append(sub)

indicater = 0
for i in range(1,3):
    for j in range(1,3):
        if  int(c[i][j]) != int(c[i][j-1]) + int(c[i-1][j]) - int(c[i-1][j-1]):
            indicater = 1

if indicater == 0:
    print('Yes')
else:
    print('No')
 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n,x;cin>>n>>x;
    if(x==1||x==2*n-1){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    vi ans(2*n-1);
    rep(i,2*n-1) ans[i]=i+1;
    swap(ans[x-1],ans[n-1]);
    swap(ans[0],ans[n-2]);
    swap(ans.back(),ans[n]);
    rep(i,2*n-1) cout<<ans[i]<<endl;
    return 0;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define MOD 1000000007
#define endl "\n"

bool pallin(string x)
{
	string a=x;
	reverse(a.begin(),a.end());
	if(x.compare(a)==0)
	{
		return 1;
	}
	else
		return 0;
}

int main()
{
	IOS;
	string s;
	cin >>s;
	int n=s.size();
	string a=s.substr(0,((n-1)/2));
	string b=s.substr((n+1)/2, n);
	//cout <<a<<" "<<b<<endl;
	if(!pallin(s))
	{
		cout <<"No"<<endl;
		return 0;
	}
	if(!pallin(a))
	{
		cout <<"No"<<endl;
		return 0;
	}
	if(!pallin(b))
	{
		cout <<"No"<<endl;
		return 0;
	}
	cout <<"Yes"<<endl;
	return 0;
}

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

int main() {
  int N, sum;
  cin >> N;
  int M =N;
  // ここにプログラムを追記
  while (N > 10) {
    sum += N % 10;
    N  = N/10;
  }
  
  sum += N;
  
  if(M%sum == 0){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll min,max;
    int N;
    cin >> N;
    int i;
    ll A;
    cin >> A;
    min=A;
    max=A;
    for(i=1;i<N;i++){
      cin >> A;
      if(A < min)min=A;
      if(A > max)max=A;
    }
    cout << max-min;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

void fun(vector<int> v,vector<pll> &re){
  sort(rall(v));
  v.pb(0);
  int n=v.size();
  re.eb(v[0],0);
  reps(i,1,n){
    re.eb(v[i],re.back().Y+i*(v[i-1]-v[i]));
  }
  reverse(all(re));
}

ll calc(vector<int> &a,int o,int t){
  ll re=0,rem=o;
  //cout<<o<<":";
  for(int x:a){
    //cout<<rem<<",";
    re+=max(0ll,x-rem);
    rem=t-min<int>(x,rem);
  }//cout<<re<<endl;
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,t;
  cin>>n>>t;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  ll l=0,r=min(t,a[0]);
  while(r-l>2){
    ll m1=(l+l+r)/3;
    ll m2=(l+r+r)/3;
    if(calc(a,m1,t) < calc(a,m2,t)) r=m2;
    else l=m1;
  }
  ll re=1e15;
  reps(i,l,r+1){
    //cout<<i<<":"<<calc(a,i,t)<<endl;
    MN(re,calc(a,i,t));
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main(){
  int n,m;cin>>n>>m;
  int i, a[m];
  lli sum =0;
  for(i=0; i<m; i++) {
    cin>>a[i];
    sum+=a[i];
  }
  if(sum<n) cout<<"No";
  else cout<<"Yes";
  return 0;
}
  

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int a,b; cin >> a >> b;
    for(int i = 1;i < 100000;i ++){
        if(i * 8 / 100 == a && i / 10 == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main() {
    	int n, m, x, a, suo[101] = {},iwa,ta;
    	cin >> n >> m >> x;
    	for (int i = 0; i < m; i++) {
    		cin >> a;
    		suo[a]++;
    	}
    	for (int i = x; i > 0 ; i--) {
    		if (suo[i] == 1) {
    			iwa++;
    		}
    	}
    	for (int i = x ; i < n + 1; i++) {
    		if (suo[i] == 1) {
    			ta++;
    		}
    	}
    	cout << min(iwa,ta) << endl;
    }

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input())-1)
    
    is_pushed = [False for i in range(N)] # 既に押されたかどうか

    i = A[0]
    ans = 1
    is_pushed[0] = True
    while True:
        if i == 1:
            print(ans)
            return
        # ボタンを押す
        if is_pushed[i]:
            print(-1)
            return
        is_pushed[i] = True
        i = A[i]
        ans += 1


if __name__ == "__main__":
    solve()


Measured memory_bytes: 7888
#include<bits/stdc++.h>
using namespace std;
int a[111111];
map<int,int> mp;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		mp[a[i]]++;
	for(int i=0;i<n;i++)
		if(mp[a[i]]!=a[i]){
			if(mp[a[i]]>a[i])
				ans+=(mp[a[i]]-a[i]);
			else
				ans+=mp[a[i]];
			mp[a[i]]=0;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) cout << "1\n";
	else cout << ((h * w + 1) >> 1) << "\n";
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> RoadSum(N, 0);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        RoadSum.at(a - 1)++;
        RoadSum.at(b - 1)++;
    }

    for (int i = 0; i < N; i++) {
        cout << RoadSum.at(i) << endl;
    }
    
}


Measured memory_bytes: 3552
import java.util.*;
import java.math.*;

public class Main {

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

    int[] p = new int[m];
    String[] s = new String[m];

    int w = 0;
    int a = 0;

    int[] data = new int[100001];

    if (m != 0) {

      for (int i = 0; i < m; i++) {
        p[i] = sc.nextInt();
        s[i] = sc.next();
      }

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

        if (s[i].equals("WA") && data[p[i]]>=0) {

          data[p[i]]++;

        } else if (s[i].equals("AC") && data[p[i]]>=0) {

          a++;
          w += data[p[i]];
          data[p[i]] = -1;

        }
      }


    }

    System.out.println(a+" "+w);

  }


}


Measured memory_bytes: 71288
class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

    def find(self, target):
        if self.parent[target] < 0:
            return target
        else:
            self.parent[target] = self.find(self.parent[target])
            return self.parent[target]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)]

    def get_root(self):
        return [i for i, root in enumerate(self.parent) if root < 0]


def main():
    n, m = map(int, input().split())
    p = list(map(int, input().split()))
    uf = UnionFind(n)
    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())
        uf.union(x, y)
    ans = 0
    for i in range(n):
        if uf.is_same(i, p[i] - 1):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20644
//08-2 JOI??¨IOI
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    bool flg = true;
    while(flg){
        string s;
        cin >> s;
        if(cin.eof()){
            flg = false;
        }
        else{
            int JOI = 0;
            int IOI = 0;
            for(int i=0; i<s.length()-2; i++){
                if(s[i]=='J' && s[i+1]=='O' && s[i+2]=='I'){
                    JOI++;
                }
                else if(s[i]=='I' && s[i+1]=='O' && s[i+2]=='I'){
                    IOI++;
                }
            }
            cout << JOI << endl;
            cout << IOI << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef long long ll;
typedef long double ld;

using namespace std;
using namespace __gnu_pbds;

void solve();

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    solve();
    return 0;
}

const int INF = 1e9;
const ll INFL = 1e18;
const double EPS = 1e-9;

void solve(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int maxX = -101, minY = 101;
    for(int i = 0; i < n; i++){
        int xi;
        cin >> xi;
        maxX = max(xi, maxX);
    }
    for(int i = 0; i < m; i++){
        int yi;
        cin >> yi;
        minY = min(yi, minY);
    }
    if(maxX < minY){
        int z = maxX + 1;
        while(z <= minY){
            if(z > x && z <= y){
                cout << "No War";
                return;
            }
            z++;
        }
    }
    cout << "War";
    return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	cout << n * (n-1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<class V> struct MaxFlow { // Dinic O(V^2E)
    struct edge { int to, reve; V cap; edge(int t, int r, V c) : to(t), reve(r), cap(c) {} };
    int MV; vector<vector<edge>> E; vector<int> itr, lev;
    MaxFlow(int n) { init(n); } MaxFlow() { }
    void init(int n){MV=n;itr=vector<int>(MV),lev = vector<int>(MV); E = vector<vector<edge>>(MV); }
    void add_edge(int x, int y, V cap, bool undir = false) {
        E[x].push_back(edge(y, (int)E[y].size(), cap));
        E[y].push_back(edge(x, (int)E[x].size() - 1, undir ? cap : 0));}
    void bfs(int cur) {rep(i, 0, MV) lev[i] = -1; queue<int> q; lev[cur] = 0; q.push(cur);
        while (q.size()) {int v = q.front(); q.pop();
        for (auto e : E[v]) if (e.cap>0 && lev[e.to]<0) lev[e.to] = lev[v] + 1, q.push(e.to);}}
    V dfs(int from,int to,V cf){if(from==to)return cf;for(; itr[from]<E[from].size(); itr[from]++) {
        edge* e = &E[from][itr[from]]; if (e->cap>0 && lev[from]<lev[e->to]) {
        V f = dfs(e->to, to, min(cf, e->cap));if(f>0){e->cap-=f;E[e->to][e->reve].cap+=f;return f; }}
        } return 0;}
    V maxflow(int from, int to) {V fl = 0, tf;while (1) {bfs(from); if (lev[to]<0) return fl;
        rep(i,0,MV)itr[i]=0; while ((tf = dfs(from, to, numeric_limits<V>::max()))>0) fl += tf;}}};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








int N, M, s, t;
int u[2020], v[2020], d[2020], c[2020];
int D[202][202];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> s >> t; s--; t--;

    rep(i, 0, N) rep(j, 0, N) D[i][j] = inf;
    rep(i, 0, N) D[i][i] = 0;

    rep(i, 0, M) {
        cin >> u[i] >> v[i] >> d[i] >> c[i];
        u[i]--; v[i]--;
        D[u[i]][v[i]] = d[i];
    }

    rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    MaxFlow<int> mf;
    mf.init(N);
    rep(i, 0, M) {
        int a = u[i], b = v[i];
        if (D[s][a] + d[i] + D[b][t] == D[s][t]) mf.add_edge(a, b, c[i]);
    }

    int ans = mf.maxflow(s, t);
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<int> v(n);
    map  <long long,long long>  even;
    map <long long,long long> odd;

    for (long long i = 0; i < n; ++i) {
        cin >> v[i];
        if(i % 2 == 0) even[v[i]] += 1;
        if(i % 2 == 1) odd[v[i]] += 1;
    }

    long long max_value = 0;
    long long max_value2 = 0;
    long long second_value = -1;
    long long second_value2 = -1;
    long long max_key =0;
    long long max_key2 = 0;
    long long res = 0;
    for (auto it = even.cbegin();it != even.cend();++it) {

        if(second_value < it->second and max_value > it->second) second_value = it->second;
        if(max_value <= it->second) {
            second_value = max_value;
            max_value = it->second;
            max_key = it->first;
        }
    }


    for (auto it = odd.cbegin();it != odd.cend();++it) {
        if(second_value2 < it->second and max_value > it->second) second_value2 = it->second;
        if(max_value2 <= it->second) {
            second_value2 = max_value2;
            max_value2 = it->second;
            max_key2 = it->first;
        }
    }

    long long res1 = 0;
    long long res2 = 0;
    cin >> res1;

    if (max_key2 == max_key){
        res1 = n - max_value - second_value2;
        res2 = n - max_value2 - second_value;
        if(res1 >= res2){
            res = res2;
        }else{
            res = res1;
        }
    }else{
        res = n - max_value - max_value2;
    }
    cout << res << endl;


}




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

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int s = 0;

        for (int i = 1; i * i <= n; ++i) {
            if (n % i == 0) {
                s += i;
                if (n / i != n && i * i != n) s += n / i;
            }
        }

        cout << ((s < n || n == 1) ? "deficient number" : s > n ? "abundant number" : "perfect number") << endl;
    }
}

Measured memory_bytes: 1152
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int k,s,ans=0;
    cin>>k>>s;
    for(int a=0;a<=k;a++)for(int b=0;b<=k;b++) if(s-a-b<=k && s-a-b>=0 ) ans++;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,num=0;
  cin >> n;
  if(n/100==n%10 && (n/10)%10==n%10){
    cout << n << endl;
  }
  else{
    if(n/100<(n/10)%10){
      num=n/100;
      num++;
      cout << num*100+num*10+num << endl;
    }
    else if(n/100==(n/10)%10 && n/100<n%10){
      num=n/100;
      num++;
      cout << num*100+num*10+num << endl;
    }
    else{
      num=n/100;
      cout << num*100+num*10+num << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> A(n);
  while (q--) {
    int op, t;
    cin >> op >> t;
    if (op == 0) {
      int x;
      cin >> x;
      A[t].push_back(x);
    } else if (op == 1) {
      for (int i = 0; i < A[t].size(); i++) {
        if (i) cout << " ";
        cout << A[t][i];
      }
      cout << endl;
    } else if (op == 2) {
      A[t].clear();
    }
  }

  return 0;
}


Measured memory_bytes: 5860
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("kyoto");
            WillReturn.Add("tokyo");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("abc");
            WillReturn.Add("arc");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("aaaaaaaaaaaaaaab");
            WillReturn.Add("aaaaaaaaaaaaaaab");
            //Yes
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];
        string T = InputList[1];

        var KaitenStrList = new List<string>();
        for (int I = 0; I <= T.Length - 1; I++) {
            char[] wkCharArr = new char[T.Length];
            int UB = wkCharArr.GetUpperBound(0);
            for (int J = 0; J <= UB; J++) {
                if (J == 0) {
                    wkCharArr[J] = T[UB];
                }
                else {
                    wkCharArr[J] = T[J-1];
                }
            }
            T = new string(wkCharArr);
            KaitenStrList.Add(T);
        }
        Console.WriteLine(KaitenStrList.Contains(S) ? "Yes" : "No");
    }
}


Measured memory_bytes: 13152