akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}


const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        //???
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
// 二項係数計算
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0 or k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//n!
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
}
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//nCr O(r) nがでかくても安心
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    //a=n!/(n-r)!=n~n-r+1までの総積->O(r)
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    //b=inv(r!)
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    // フェルマーの小定理
    return pow_mod(n,mod-2);
}

int n;
vector<vector<int>> g;
vector<ll> dp,ans,ko;

int dfs0(int pre,int now){
    int ret=1;
    for(auto to:g[now])if(to!=pre) ret+=dfs0(now,to);
    return ko[now]=ret;
}

ll dfs1(int pre,int now){
    ll res=1,kosum=0;
    for(auto to:g[now])if(to!=pre){
        kosum+=ko[to];
        res*=dfs1(now,to);res%=mod;
        res*=inv_mod(fac[ko[to]]);res%=mod;
    }
    res*=fac[kosum];res%=mod;
    return dp[now]=res;
}

void dfs2(int pre,int now,ll pres){
    ll res=pres*inv_mod(fac[n-ko[now]])%mod*fac[n-1]%mod;
    for(auto to:g[now])if(to!=pre){
        res*=inv_mod(fac[ko[to]]);res%=mod;
        res*=dp[to];res%=mod;
    }
    ans[now]=res;
    for(auto to:g[now])if(to!=pre){
        dfs2(now,to,res*inv_mod(dp[to])%mod*fac[ko[to]]%mod*fac[n-1-ko[to]]%mod*inv_mod(fac[n-1])%mod);
    }
}

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

    cin>>n;
    g.resize(n);dp.resize(n);
    ans.resize(n);ko.resize(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs0(-1,0);
    dfs1(-1,0);
    dfs2(-1,0,1);
    // debug(dp);debug(ko);
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}


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

const int NMAX = 1e5, CMAX = 30;

int n, c;
int tv[CMAX + 2][NMAX + 2];

int ans;

int main()
{
    cin >> n >> c;
    for(int i = 1; i <= n; i++)
    {
        int s, t, ch;
        cin >> s >> t >> ch;

        for(int j = s - 1; j < t; j++)
            tv[ch][j] = 1;
    }

    for(int i = 1; i <= NMAX; i++)
    {
        int rec = 0;
        for(int j = 1; j <= CMAX; j++)
            rec += tv[j][i];

        ans = max(ans, rec);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H , W;
  cin >> H >> W;
  vector<vector<char>> hyo(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> hyo.at(i).at(j);
    }
  }
   int count = 0;
   for (int i = 0; i < W; i++){
     bool tate_check =true;
     for (int j = 0; j < H; j++){
       if (hyo.at(j).at(i - count) != '.'){
         tate_check = false;
         break;
       }
     }
     if (tate_check == true){
       for (int k = 0; k < H; k++){
         for (int l = i - count; l < W - 1; l++){
            hyo.at(k).at(l) = hyo.at(k).at(l + 1);
         }
       }
       count++;
     }
   }
   for (int i = 0; i < H; i++){
     bool yoko_check = true;
     for (int j = 0; j < W; j++){
       if (hyo.at(i).at(j) != '.'){
         yoko_check = false;
         break;
       }
     }
     if (yoko_check == false){
       for (int j = 0; j < W - count; j++){
         cout << hyo.at(i).at(j);
       }
       cout << endl;
     }
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<bool> map((h+2)*(w+2));
    for (int y = 1; y <= h; y++) {
        string s;
        cin >> s;
        for (int x = 1; x <= w; x++) {
            if (s[x-1] == '#') map[(w+2)*y+x] = true;
        }
    }
    for (int y = 1; y <= h; y++) {
        for (int x = 1; x <= w; x++) {
            if (map[(w+2)*y+x] && !map[(w+2)*(y-1)+x] && !map[(w+2)*(y+1)+x] && !map[(w+2)*y+x-1] && !map[(w+2)*y+x+1]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define pb push_back
#define pi 3.14159265358979323846264338327950288419716939937510
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 100
using namespace std;

int main()
{
    RUN_FAST;
    int n, k, x;
    vector <int> v;
    cin >> n >> k;
    while (n--) {
        cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());
    int sum=0;
    for (int i=0; i<k; i++) sum+=v[i];
    cout << sum << endl;
    return 0;
}


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

int main(){
  int a,b;
  int x;
  int i;

  scanf("%d", &x);

  a = 1000;
  b = 1000;

  if(x == 1){
    printf("Yes\n");
    return 0;
  }

  for(i = 9;i >= 2;i--){
    if(x % i == 0){
      a = i;
      x = x/i;
      b = x;
      break;
    }
  }

  if(a > 9 || b > 9) printf("No\n");

  else printf("Yes\n");

  return 0;
}


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

#define int int64_t

using namespace std;

#define MAX 200005

int n, k, a[MAX], dp[MAX];

int f(int i)
{
    if (dp[i] != -1)
        return dp[i];
    if (i == n - 1)
        return 0;
    dp[i] = f(i + 1) + abs(a[i + 1] - a[i]);
    for (int j = 2; i + j < n && j <= k; j++)
        dp[i] = min(dp[i], f(i + j) + abs(a[i + j] - a[i]));
    // if (i == n - 2)
    //     else
    //     {

    //         dp[i] = min(f(i + 1) + abs(a[i + 1] - a[i]), f(i + 2) + abs(a[i + 2] - a[i]));
    //     }
    return dp[i];
}

signed main()
{
    scanf("%lld %lld", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", a + i);
        dp[i] = -1;
    }
    printf("%lld\n", f(0));
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=10000050;

ll f[maxn];
int main()
{
	ll n,ans=0;
	cin>>n;
	for(int i=1;i<=n;++i)
	  for(int j=i;j<=n;j+=i) 
	    f[j]++;
	for(int i=1;i<=n;++i)
	  ans=ans+i*f[i];
	cout<<ans<<endl;      
}


Measured memory_bytes: 81712
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
    {
     ll int n;
     cin>>n;
     vl ar(n+1);
     ll int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i];
        if(i%2!=0&&ar[i]%2!=0)
        ans++;
    }
  cout<<ans<<endl;
  
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}






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

int n=100,x;

signed main()
{
	cin>>x;
	for (int i=1;i<=40000;i++)
	{
		n=n*1.01;
		if (n>=x)  return cout<<i<<endl,0;
	}
}

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

ll n,b,a,ans;

int main(){
    cin>>n;
    rep(i,n){
        cin>>a;
        if(a>b+1){
            ans+=(a-1)/(b+1);
            a=1;
        }
        b=max(a,b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n; cin >> n;
  int v[n], c[n];
  REP(i,n) cin >> v[i];
  REP(i,n) cin >> c[i];
  int val[n];
  REP(i,n) val[i] = v[i]-c[i];
  ll ans = 0;
  REP(i,n){
    if(val[i]>0) ans += val[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int x; cin >> x;
	cout << (x == 7 || x == 5 || x == 3 ? "YES": "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            int[] a = Stream.of(sc.nextLine().split(" "))
                    .mapToInt(Integer::parseInt)
                    .toArray();
            int c = partition(a, 0, a.length - 1);
            StringJoiner sj = new StringJoiner(" ");
            for (int i = 0; i < a.length; i++) {
                if (i == c) {
                    sj.add("[" + a[i] + "]");
                    continue;
                }
                sj.add(Integer.toString(a[i]));
            }
            System.out.println(sj.toString());
        } catch (NoSuchElementException | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static int partition(int[] a, int p, int r) {
        int x = a[r];
        int i = p - 1;
        for (int j = p; j < r + 1; j++) {
            if (a[j] <= x) {
                i = i + 1;
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
        return i;
    }
}



Measured memory_bytes: 55112
import sys 
from functools import reduce
from math import gcd
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7
N = int(readline())
A = list(map(int,readline().split()))
lcm = reduce(lambda x,y:x*y//gcd(x,y),A)
ans = 0
coef = sum(pow(x,mod-2,mod) for x in A)
ans = lcm * coef % mod
print(ans)

Measured memory_bytes: 10448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		char[] wk;

		try {
			scanner = new Scanner(System.in);
			wk = scanner.nextLine().toCharArray();

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (wk[i] == '1') {
					res++;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int divide(int[] wk) {
		int res = 0;
		boolean isComplete = true;
		for (int i = 0; i < wk.length; i++) {
			if (wk[i] % 2 == 0) {
				wk[i] /= 2;
			} else {
				isComplete = false;
			}
		}
		if (isComplete) {
			res = divide(wk) + 1;
		}
		return res;
	}

	private void solveB() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();

			int[] wk = new int[n];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			System.out.println(divide(wk));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

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

	if (A + B == C + D) cout << "Balanced";
	else if (A + B > C + D) cout << "Left";
	else cout << "Right";

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long

void solve()
{
    ll n,m;cin>>n>>m;
    
    ll ans = (n*(n-1))/2 ;
    ans += (m*(m-1))/2;
    cout<<ans<<endl;

}

int main() {
    
    // ll t;cin>>t;while(t--)
    {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 256
#64c
N = int(input()) #N<100
a_list = [int(e) for e in input().split()]

color_and_number_of_persons={"gray":0,"brown":0,"green":0,"cyan":0,"blue":0,"yellow":0,"orange":0,"red":0,"other":0}
color_and_min_rate={"gray":1,"brown":400,"green":800,"cyan":1200,"blue":1600,"yellow":2000,"orange":2400,"red":2800,"other":3200}

color_and_min_rate = sorted(color_and_min_rate.items(), reverse=True, key=lambda x : x[1])

for rate in a_list:
    #print(rate,":",end="")
    for c_and_mr in color_and_min_rate:
        if rate >= c_and_mr[1]:
            #print(c_and_mr[0])
            color_and_number_of_persons[c_and_mr[0]] += 1
            break
            
#print(color_and_number_of_persons)

number_of_color = 0

for number_of_persons in color_and_number_of_persons.values():
    if number_of_persons != 0:
        number_of_color += 1
        
if color_and_number_of_persons["other"] != 0:
    number_of_color -= 1 #number_of_colorはレート3200以上も含んでいるので、それは差し引く
    
if number_of_color == 0:
    min_ans = 1
    max_ans = color_and_number_of_persons["other"]
else:
    min_ans = number_of_color
    max_ans = number_of_color + color_and_number_of_persons["other"]

print(min_ans,max_ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,m;
    cin>>n>>m;

    ll ans=0;
    VP edge(m);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        edge[i]=mp(a,b);
    }

    rep(i,m){
        VV dist(n,Vec(n,INF));
        rep(j,n){
            dist[j][j] = 0;
        }
        rep(j,m){
           if(j==i)continue;
            P &p = edge[j];
            dist[p.fi][p.se] = dist[p.se][p.fi] = 1;
        }
        rep(k,n){
            rep(a, n){
                rep(b, n) {
                    dist[a][b] = min(dist[a][b], dist[a][k]+dist[k][b]);
                }
            }
        }
        bool connect = true;
        rep(a,n){
            rep(b,n){
                if(dist[a][b]>=INF){
                    connect = false;
                    goto chk;
                }
            }
        }
        chk:
        if(!connect){
            ans++;
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; LL D; cin >> N >> D;	
	vector<LL> A(N),r(N);
	repp(i,0,N){
		cin >> A[i];
		r[i] = i;
	}
	sort(r.begin(),r.end(),[&](const int &u, const int &v){return A[u]+u*D < A[v]+v*D;});
	int p = 0;
	LL m = A[0];
	LL ans = 0;
	repp(i,0,N) if(r[i] > p){
		LL z = A[r[i]]-r[i]*D;
		++p;
		while(p < r[i]){
			if(m+A[p]+p*D < A[r[i]]+r[i]*D+A[p]-p*D){
				ans += m+A[p]+p*D;
				m = min(m,A[p]-p*D);
			} else {
				ans += A[r[i]]+r[i]*D+A[p]-p*D;
				z = min(z,A[p]-p*D);
			}
			++p;
		}
		ans += m+A[r[i]]+r[i]*D;
		m = min(m,z);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
n, m = list(map(int, input().split()))
left_max = -1
right_min = 10**10
for i in range(m):
  l, r = list(map(int, input().split()))
  left_max = max([left_max, l])
  right_min = min([right_min, r])
print(len([i for i in range(1, n+1) if left_max <= i and i <= right_min]))

Measured memory_bytes: 7088
#include <iostream>
#include <numeric>

int main() {
    int a[4],b[4];
    for(int i=0;i<4;i++) scanf("%d",&a[i]);
    for(int i=0;i<4;i++) scanf("%d",&b[i]);
    
    int as=std::accumulate(a,a+4, 0), bs=std::accumulate(b,b+4, 0);
    as > bs ? std::cout << as << std::endl : std::cout << bs << std::endl;
    
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n; long long r[200000]={}, m = 10000000000, M =-2000000000 ;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> r[i];
        
        M = max(M, r[i]-m);
        m = min(m, r[i]);
    }
    cout << M << endl;
}


Measured memory_bytes: 4660
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <numeric>
using namespace std;

template <class T>
bool chmin(T &x,T y)
{
    if(x>y)
    {
        x=y;
        return true;
    }
    return false;
}

main()
{
    int n,m,S; cin>>n>>m>>S;
    if(S>2500) S=2500;

    struct edge {int to,fee; long long cost;};
    vector<edge> g[55];
    for(int i=0; i<m; ++i)
    {
        int a,b; cin>>a>>b; --a,--b;
        int c,d; cin>>c>>d;
        g[a].push_back({b,c,d});
        g[b].push_back({a,c,d});
    }

    vector<int> c(n),d(n);

    long long inf=1e18,dp[55][2727];
    for(int i=0; i<n; ++i)
    {
        cin>>c[i]>>d[i];
        fill(begin(dp[i]),end(dp[i]),inf);
    }

    dp[0][S]=0;

    struct state {int city, silv; long long time;};
    auto comp=[&](state &x, state &y)->bool
    {
        return x.time>y.time;
    };

    priority_queue<state, vector<state>, decltype(comp)> que(comp);
    que.push({0,S,0});

    // queue<pair<int,int>> que;
    while(!que.empty())
    {
        auto f=que.top(); que.pop();
        // cerr << "\t" << f.city << " " << f.silv << " " << f.time << endl;
        if(f.time!=dp[f.city][f.silv]) continue;
        for(auto &e: g[f.city])
        {
            if(f.silv<e.fee) continue;
            if(chmin(dp[e.to][f.silv-e.fee], f.time+e.cost))
            {
                que.push({e.to, f.silv-e.fee, dp[e.to][f.silv-e.fee]});
            }
        }
        if(f.silv<2500 and chmin(dp[f.city][f.silv+c[f.city]],f.time+d[f.city]))
        {
            que.push({f.city, f.silv+c[f.city], f.time+d[f.city]});
        }
    }

    for(int i=1; i<n; ++i)
    {
        cout << *min_element(begin(dp[i]),end(dp[i])) << "\n";
    }
}

Measured memory_bytes: 6408
N = int(input())
A = list(map(int, input().split()))

a = [0]
for i in range(N):
    a.append(a[i] + A[i])

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

mod = 10 ** 9 + 7
ans = cnt % mod
print(ans)


Measured memory_bytes: 31612
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		Set<Character> set = new HashSet<>();
		String line = in.readLine();
		for (Character c : line.toCharArray()) {
			set.add(c);
		}
		System.out.println((set.size() == 2 ? "Yes" : "No"));
	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 21076
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var A [5]int
	for i := 0; i < 5; i++ {
		fmt.Scan(&A[i])
	}
	ans := 0
	time := 0
	for i := 0; i < 5; i++ {
		hoge := (A[i] + 9) / 10 * 10
		time = max(time, hoge-A[i])
		ans += hoge
	}
	ans -= time
	fmt.Println(ans)
}


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

bool search(string str, char ch){
    int i = 0;
    while(str[i] != '\0'){
        if(str[i] < ch){
            return true;
        }
        i++;
    }
    return false;
}

bool count(string str1, string str2){
    for(int i = 0; i < str1.size(); i++){
        for(int j = 0; j < str2.size(); j++){
            if(str1[i] != str2[j]){
                return false;
            }
        }
    }
    return true;
}

int main(){
    string str1, str2;
    cin >> str1 >> str2;

    sort(str1.begin(), str1.end());
    sort(str2.begin(), str2.end());
    
    int i = str2.size() - 1;
    while(true){
        if(i < 0){
            break;
        }
        bool flag = search(str1, str2[i]);
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
        i--;
    }

    bool cnt = count(str1, str2);
    if(cnt){
        if(str2.size() > str1.size()){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

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

    int cnt = 0;
    while(a > 0 && c > 0){
        if(cnt % 2 == 0){
            c -= b;
        }else{
            a -= d;
        }
        cnt ++;
    }


    if(a <= 0){
        cout << "No" <<endl;
    }else{
        cout << "Yes" <<endl;
    }
}


Measured memory_bytes: 3652
main :: IO ()
main = do
  let xs = [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]
  n <- readLn :: IO Int
  print $ xs !! (n - 1)


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

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

	vi v(n);
	for (int i = 0; i < n; i++){
		cin>>v[i];
	}

	if(n==1&&v[0]==1){
		cout<<0<<endl;
		return 0;
	}

	int j=1;
	for (int i = 0; i < n; i++){
		if(v[i]==j){
			j++;
		}
	}

	if(j==1){
		cout<<-1<<endl;
	}else{
		cout<<n-j+1<<endl;
	}



	return 0;
}

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

using namespace std;
using ll = long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n, sum = 0;
  cin >> n;
  FOR(i, 1, n + 1) {
    if (i % 3 != 0 && i % 5 != 0) sum += i;
  }
  OUT(sum);

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  int n,k;
  std::cin >> n>>k;
  int r,s,p;
  std::cin >> r>>s>>p;
  string t;
  std::vector<bool> tt(n);
  int ans=0;
  std::cin >>t;
  rep(i,n){
    if(i+1<k){
          tt[i]=1;
          if(t[i]=='r')ans+=p;
          if(t[i]=='s')ans+=r;
          if(t[i]=='p')ans+=s;
    }else{
      if(t[i]==t[i-k]){
        if(tt[i-k]){
          tt[i]=0;
        }
        else{
          tt[i]=1;
          if(t[i]=='r')ans+=p;
          if(t[i]=='s')ans+=r;
          if(t[i]=='p')ans+=s;
        }
      }
      else{
        tt[i]=1;
          if(t[i]=='r')ans+=p;
          if(t[i]=='s')ans+=r;
          if(t[i]=='p')ans+=s;
      }
    }
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if((a + b) % 2 == 0)
    out((a + b) / 2);
  else
    out("IMPOSSIBLE");
  memi;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	//n, _ := strconv.Atoi(s.Text())
	s.Scan()
	m, _ := strconv.Atoi(s.Text())

	l := make([]int, m)
	r := make([]int, m)
	for i := 0; i < m; i++ {
		s.Scan()
		l[i], _ = strconv.Atoi(s.Text())
		s.Scan()
		r[i], _ = strconv.Atoi(s.Text())
	}

	var min, max int
	max = 0
	for _, v := range l {
		if v > max {
			max = v
		}
	}

	min = 100000
	for i := range r {
		if r[i] < min {
			min = r[i]
		}
	}
	if min >= max {
		fmt.Println(min - max + 1)
	} else {
		fmt.Println(0)
	}

}


Measured memory_bytes: 3328
from sys import setrecursionlimit
setrecursionlimit(10**5)

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

class UnionFind(list) :
    def __init__(self, n) :
        super().__init__(range(n))
        self.dic = {i:1 for i in range(n)}
        self.fubensa = n*(n-1)//2

    def find(self, i) :
        if self[i] == i : return i
        self[i] = self.find(self[i])
        return self[i]

    def union(self, x, y) :
        x = self.find(x)
        y = self.find(y)
        self[y] = x
        if x != y :
            self.fubensa -= self.dic[x]*self.dic[y]
            self.dic[x] += self.dic[y]
            del self.dic[y]

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

uf = UnionFind(n)
ans = []
for a, b in reversed(ab) :
    ans.append(uf.fubensa)
    uf.union(a-1, b-1)
    
for a in reversed(ans) :
    print(a)

Measured memory_bytes: 49460
n,m=map(int,input().split())
s=[]
for _ in range(n):
  a,b=map(int,input().split())
  s.append((a,b))

s=sorted(s,key=lambda x:x[0])
cost=0
for i in range(n):
  if m>s[i][1]:
    m-=s[i][1]
    cost+=s[i][0]*s[i][1]
  else:
    cost+=s[i][0]*m
    m=0
print(cost)

Measured memory_bytes: 18948
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    ll tmp = N % 10;
    if (tmp == 2 or tmp ==4 or tmp == 5 or tmp == 7 or tmp == 9) {
        cout << "hon" << endl;
    } else if (tmp == 0 or tmp == 1 or tmp == 6 or tmp == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}

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

int main() { 
 long long a,v,b,w,t,c;
  cin>>a>>v>>b>>w>>t;
  bool ok=false;
  c=abs(b-a);
  if(c<=(v-w)*t)ok=true;
  if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

public class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int Y = int.Parse(input[1]);
        int x = -1,
            y = -1,
            z = -1;
        int c;
        for (int a = 0; a <= N; a++)
        {
            for (int b = 0; a + b <= N; b++)
            {
                c = N - a - b;
                if(10000 * a + 5000 * b + 1000 * c == Y)
                {
                    x = a;
                    y = b;
                    z = c;
                }
            }
        }
        Console.WriteLine($"{x} {y} {z}");
    }
}

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

#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<size;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define mod 1000000007
#define modpro 99824435

const int d8i[8]={-1,0,1,0,-1,1,1,-1},d8j[8]={0,1,0,-1,1,1,-1,-1};


void solve(){
	int n;
	cin>>n;
	if(n>=400 && n<=599){
		cout<<8;
		return;
	}
	if(n>=600 && n<=799){
		cout<<7;return;
	}
	if(n>=800 && n<=999){
		cout<<6;return;
	}
	if(n>=1000 && n<=1199){
		cout<<5;return;
	}
	if(n>=1200 && n<=1399){
		cout<<4;return;
	}
	if(n>=1400 && n<=1599){
		cout<<3;return;
	}
	if(n>=1600 && n<=1799){
		cout<<2;return;
	}
	if(n>=1800 && n<=1999){
		cout<<1;return;
	}
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
}



Measured memory_bytes: 3648
import java.util.*;
class Main
{
	public static void main(String[] args)                                        
	{
		Scanner sc=new Scanner(System.in);
		int t;
		t=sc.nextInt();
		double a=2*Math.PI*t;
		System.out.println(a);
		 
	
		
	}
	
	
			
	
		
}



Measured memory_bytes: 27144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int >v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end());
    if(v[0]==5&&v[1]==5&&v[2]==7)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

const int MAX_V = 100000;
const int MAX_E = 300000;

int par[MAX_V]; //parents
int rnk[MAX_V]; //depth of the tree
struct edge { int u, v; ll cost; };
edge es[MAX_E];
int V, E;//node,edge

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

//initialize with n elements
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
//find a root of the tree
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//merge the sets contains x,y
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rnk[x] < rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}
//the set contains x and y or not
bool same(int x, int y) {
	return find(x) == find(y);
}

ll kruskal() {
	sort(es, es + E, comp);
	init(V);
	int res = 0;
	for (int i = 0; i < E; i++) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main() {
	cin.sync_with_stdio(false);
	cin >> V;
	vector<ll>x(V), y(V);
	rep(i, V)cin >> x[i] >> y[i];
	vector<pair<ll, int>>ex, ey;
	rep(i, V) {
		ex.push_back({ x[i],i });
		ey.push_back({ y[i],i });
	}
	sort(ex.begin(), ex.end());
	sort(ey.begin(), ey.end());
	E = 0;
	reps(i,1, V) {
		es[E].u = ex[i].second;
		es[E].v = ex[i-1].second;
		es[E].cost = ex[i].first - ex[i - 1].first;
		E++;
		es[E].u = ey[i].second;
		es[E].v = ey[i - 1].second;
		es[E].cost = ey[i].first - ey[i - 1].first;
		E++;
	}
	
	cout << kruskal() << endl;





	return 0;
}

Measured memory_bytes: 10212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    Cout(s == "Sunny" ? "Cloudy" : s == "Cloudy" ? "Rainy" : "Sunny");
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int A,S,D,F;
  cin>>A>>S>>D>>F;
  A+=S;
  D+=F;
  if(A>D)cout<<"Left"<<endl;
  else if(A==D)cout<<"Balanced"<<endl;
  else cout<<"Right"<<endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_V = 20000+5;
using CAP = ll;
using COST = ll;
const ll INF = (ll)1e9;

struct State {
  COST dist;
  int pos;
  bool operator < (const State &o) const {
    return dist > o.dist; // reverse order
  }
};
struct Edge{ int to; CAP cap; COST cost; int rev; };
vector<Edge> adj[MAX_V];
COST potential[MAX_V];
COST dist[MAX_V];
int prevv[MAX_V];
int preve[MAX_V];
void clearedge() { REP(i, MAX_V) adj[i].clear(); }
void addedge(int u, int v, CAP cap, COST cost) {
  adj[u].push_back( (Edge){v, cap, cost, (int)adj[v].size() + (u == v)} );
  adj[v].push_back( (Edge){u, 0, -cost, (int)adj[u].size() - 1} );
}

// sからtへ流量 flow を流す最小コストを返す。
// 流せない場合は INF を返す
COST mincost_maxflow(int s, int t, CAP flow) {
  vector<int> vs;
  REP(i, MAX_V) if (adj[i].size()) vs.push_back(i);
  int res = 0;
  for (int v : vs) potential[v] = 0;
  while (flow > 0) {
    for (int v : vs) dist[v] = INF;
    priority_queue<State> q;
    q.push({0, s});
    dist[s] = 0;
    while (!q.empty()) {
      State crt = q.top(); q.pop();
      if (dist[crt.pos] < crt.dist) continue;
      REP(i, adj[crt.pos].size()) {
        const Edge&e = adj[crt.pos][i];
        COST n_dist = crt.dist + e.cost + potential[crt.pos] - potential[e.to];
        if (e.cap > 0 && dist[e.to] > n_dist) {
          dist[e.to] = n_dist;
          prevv[e.to] = crt.pos;
          preve[e.to] = i;
          q.push({dist[e.to], e.to});
        }
      }
    }
    if (dist[t] == INF) return INF;
    for (int v : vs) potential[v] += dist[v];
    CAP f = flow;
    for (int v = t; v != s; v = prevv[v]) {
      f = min(f, adj[prevv[v]][preve[v]].cap);
    }
    for (int v = t; v != s; v = prevv[v]) {
      Edge &e = adj[prevv[v]][preve[v]];
      e.cap -= f;
      adj[v][e.rev].cap += f;
    }
    flow -= f;
    res += f * potential[t];
  }
  return res;
}

int main2() {
  int V = nextLong();
  int E = nextLong();
  int F = nextLong();

  clearedge();
  REP(i, E) {
    int a = nextLong();
    int b = nextLong();
    int c = nextLong();
    int d = nextLong();
    addedge(a, b, c, d);
  }
  ll ans = mincost_maxflow(0, V-1, F);
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main() {

	ll n; cin >> n;
	vector<ll> h(n);
	for (ll i = 0; i < n; i++) {
		cin >> h[i];
	}
	ll tmp = 0;
	ll ans = 0;
	for (ll i = 0; i < n - 1 ; i++) {
		if (h[i] >= h[i + 1]) {
			tmp++;
			ans = max(ans, tmp);
		}
		else {			
			tmp = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3980
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,ans=3; cin>>n;
    rep(i,n){
        char ch; cin>>ch;
        if(ch=='Y') ans=4;
    }
    cout<<(ans==3 ? "Three" : "Four")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;


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

	if(A<0||A>1000){
		cout<<"No"<<endl;
		return 0;
	}
	if(N<1||A>10000){
		cout<<"No"<<endl;
		return 0;
	}
	
	if(A>=N){
		cout<<"Yes"<<endl;
		return 0;
	}
	else{
		while(N>=500){
			N = N - 500;
		}
		if(A>=N){
			cout<<"Yes"<<endl;
			return 0;
		}
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int t,n,s,f;
  while( cin >> t , t ){

    cin >> n;
    int time = 0;
    for( int i = 0 ; i < n ; i++ ){
      cin >> s >> f;
      time += ( f - s );
    }
    if( time >= t ) cout << "OK" << endl;
    else cout << t - time << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) rep2(i,0,n)

using namespace std;

main(){
    int n,m;
    cin>>n>>m;
    cout<<(n*100+m*1800)*pow(2,m);
    return 0;
}

Measured memory_bytes: 256
MIN=set()
tourist=0

n=int(input())
a=list(map(int,input().split()))

for i in range(n):
  if a[i]>=3200:
    tourist+=1
  else:
    for g in range(1,9):
        low=(g-1)*400
        high=g*400-1
        if low<=a[i] and a[i]<=high:
          MIN.add(g)

if len(MIN)==0:
  print(1,tourist)
else:
  print(len(MIN),len(MIN)+tourist)

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

int main(){
	
  int a,b,c;
  cin>>a>>b>>c;
 map<int,int> m;
  m[a]++;
  m[b]++;
  m[c]++;
  cout<<m.size()<<endl;
  
}


Measured memory_bytes: 256
/*
^-^ THINK SIMPLE ^-^
^-^ THINK FAST ^-^
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define mod 1000000007
#define siz 100001

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n,m;
	cin >> n >> m;
	
	ll x,y, d = 0;
	double sums;
	for(ll i = 0; i < n; i++){
		cin >> x >> y;
		sums = sqrt(pow(x, 2) + pow(y, 2));
		if(sums <= m){
			d++;
		}
	}
	cout << d << "\n";
}























Measured memory_bytes: 3664