akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;

int n,m,G;

vector<int> t[30];
int u[30];
map<int,int> dp;

int solve(int S){
  if(S==G)return 0;
  if(dp[S]>0)return dp[S];

  int k;
  for(k=0;k<n;k++){
    if( (S>>k)&1 )continue;
    break; 
  }

  int res=100;
  for(int i=0;i<(int)t[k].size();i++){
    int w=t[k][i];
    res=min(res, solve(S|u[w])+1 );
  }
  return dp[S]=res;
}


int main(){
  int a,b;
  while(cin>>n>>m){
    if(n==0&&m==0)break;

    dp.clear();
    for(int i=0;i<n;i++)t[i].clear();

    for(int i=0;i<m;i++){
      cin>>a>>b;
      t[a].push_back(b);
      t[b].push_back(a);
    }

    for(int i=0;i<n;i++){
      u[i]=(1<<i);
      t[i].push_back(i);
      for(int j=0;j<(int)t[i].size();j++){
	u[i]|=(1<<t[i][j]);
      }
    }

    G=(1<<n)-1;			      
    cout<<solve(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
using ll = long long int;
using P = pair<int, int>;

const int MAX_V = 1e6 + 10;
const double INF = 4 * 1e9;
struct edge{
    int to;
    double cost;
};
vector<edge> graph[MAX_V];
vector<double> d(MAX_V);

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i=0; i<(int)graph[v].size(); i++){
            edge e = graph[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
    int n; cin >> n;
    vector<vector<double>> nodes;
    for(int i=0; i<n; i++){
        double xn, yn, rn; cin >> xn >> yn >> rn;
        nodes.push_back(vector<double>{xn, yn, rn});
    }
    double dx = xt - xs;
    double dy = yt - ys;
    double distance = sqrt(dx * dx + dy * dy);
    edge e1; e1.to = 0; e1.cost = distance;
    graph[n+1].push_back(e1); 
    edge e2; e2.to = n+1; e2.cost = distance;
    graph[0].push_back(e2); 
    for(int i=0; i<n; i++){
        double dx = nodes[i][0] - xs;
        double dy = nodes[i][1] - ys;
        double distance = max(0.0, sqrt(dx * dx + dy * dy) - nodes[i][2]);
        if(i+1 != 0){
            edge e1; e1.to = 0; e1.cost = distance;
            graph[i+1].push_back(e1); 
            edge e2; e2.to = i+1; e2.cost = distance;
            graph[0].push_back(e2); 
        }
        dx = nodes[i][0] - xt;
        dy = nodes[i][1] - yt;
        distance = max(0.0, sqrt(dx * dx + dy * dy) - nodes[i][2]);
        if(i+1 != n+1){
            edge e1; e1.to = n+1; e1.cost = distance;
            graph[i+1].push_back(e1); 
            edge e2; e2.to = i+1; e2.cost = distance;
            graph[n+1].push_back(e2); 
        }
        for(int j=i+1; j<n; j++){
            dx = nodes[i][0] - nodes[j][0];
            dy = nodes[i][1] - nodes[j][1];
            distance = max(0.0, sqrt(dx * dx + dy * dy) - nodes[i][2] - nodes[j][2]);
            edge e1; e1.to = j+1; e1.cost = distance;
            graph[i+1].push_back(e1); 
            edge e2; e2.to = i+1; e2.cost = distance;
            graph[j+1].push_back(e2); 
        }
    }
    // for(auto& v:graph){
    //     for(auto& w:v){
    //         cout << w.to << " " << w.cost << endl;
    //     }
    // }

    dijkstra(0);
    // for(int i=0; i<10; i++){
    //     cout << d[i] << " ";
    // }
    // cout << endl;
    cout << setprecision(12);
    cout << d[n+1] << endl;

    return 0;
}

Measured memory_bytes: 50036
n=int(input())
a=list(map(int,input().split( )))
m=int(input())
b=list(map(int, input().split()))

a.sort()
b.sort()
ans = [0]*m
i = 0 #b
j = 0 #a
while i<m and j<n:
    if b[i] < a[j]:
        i += 1
    elif b[i] == a[j]:
        ans[i] = 1
        j += 1
    else:
        j+=1
flag = 1
for i in range(m):
    if ans[i] == 0:
        flag = 0
print(flag)
        


Measured memory_bytes: 35280
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N, P;
	cin >> N >> P;
	string s;
	cin >> s;

	if (P == 2) {
		ll kotae = 0;
		rep(i, N) {
			if((s[i] - '0') % 2 == 0) kotae += i + 1;
		}
		co(kotae);
		return 0;
	}
	if (P == 5) {
		ll kotae = 0;
		rep(i, N) {
			if ((s[i] - '0') % 5 == 0) kotae += i + 1;
		}
		co(kotae);
		return 0;
	}

	map<int, int> MP;
	MP[0] = 1;
	ll kotae = 0;
	int ima = 1;
	int mae = 0;
	rep(i, N) {
		int a = s[N - 1 - i] - '0';
		a = (a * ima + mae) % P;
		kotae += MP[a];
		MP[a]++;
		mae = a;

		ima = ima * 10 % P;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 916
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

int main(int argc, char *argv[]) {
	
	int n, k;
	cin >> n >> k;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t >= k) res++;
	}
	cout << res << endl;
	
}














Measured memory_bytes: 256
import java.util.*;
	import java.io.*;
	import java.math.*;
	 
	 
	import static java.lang.Math.*;
	import static java.util.Arrays.*;
	import static java.util.Collections.*;
	 
	 
	public class Main{ 
	 
	 
	    static long mod=1000000007;
	    static int dx[]={1,-1,0,0};
	    static int dy[]={0,0,1,-1};
	    // static int dx[]={1,-1,0,0,1,1,-1,-1};
	    // static int dy[]={0,0,1,-1,1,-1,1,-1};
	    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
	    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
	 
	public  static void main(String[] args)   throws Exception, IOException{
	 
	    
	    Reader sc = new Reader(System.in);
	    PrintWriter out=new PrintWriter(System.out);
	 
	    int n=sc.nextInt();
	    int a[]=new int[n];
	    int b[]=new int[n];
	    int c[]=new int[n];
	    long d[]=new long[n];
	    long ans=0;
	    for (int i=0; i<n; i++) {
	    	a[i] = sc.nextInt();
		}for (int i=0; i<n; i++) {
	    	b[i] = sc.nextInt();
		}for (int i=0; i<n; i++) {
	    	c[i] = sc.nextInt();
		}
		sort(a);
		sort(b);
		sort(c);
		for (int i=0; i<n; i++) {
			int x=-1,h=n,l=0,md=0;
			for (int t=0; t<70; t++) {
				md = (h+l) / 2;
				if(a[md]<b[i]){x=md; l=md;}
				else h=md;
			}
			d[i] += x+1;
		}
		// db(d);	
		for (int i=0; i<n-1; i++) {
			d[i+1] += d[i];
		}
		for (int i=0; i<n; i++) {
			int x=-1,h=n,l=0,md=0;
			for (int t=0; t<70; t++) {
				md = (h+l) / 2;
				if(b[md]<c[i]){x=md; l=md;}
				else h=md;
			}
			if(x>=0)
			ans += d[md];
		}

		out.println(ans);
	    out.flush();
	}
	 
	static void db(Object... os){
	 
	    System.err.println(Arrays.deepToString(os));
	 
	}
	 
	static boolean validpos(int x,int y,int r, int c){
	    
	    return x<r && 0<=x && y<c && 0<=y;
	    
	}
	 
	static boolean bit(long x,int k){
	    // weather k-th bit (from right) be one or zero
	    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
	}
	 
	}
	 
	 
	class XY {
	    int x,y,d;
	    XY(int x, int y, int d) {
	        this.x=x;
	        this.y=y;
	        this.d=d;
	    } 
	}
	 
	class P implements Comparable<P>{
	    int x,y;
	    P(int x, int y) {
	        this.x=x;
	        this.y=y;
	    } 
	      
	    public int compareTo(P p){
	        return -x + p.x;//des
	    } 
	}
	 
	class Reader
	{ 
	    private BufferedReader x;
	    private StringTokenizer st;
	    
	    public Reader(InputStream in)
	    {
	        x = new BufferedReader(new InputStreamReader(in));
	        st = null;
	    }
	    public String nextString() throws IOException
	    {
	        while( st==null || !st.hasMoreTokens() )
	            st = new StringTokenizer(x.readLine());
	        return st.nextToken();
	    }
	    public int nextInt() throws IOException
	    {
	        return Integer.parseInt(nextString());
	    }
	    public long nextLong() throws IOException
	    {
	        return Long.parseLong(nextString());
	    }
	    public double nextDouble() throws IOException
	    {
	        return Double.parseDouble(nextString());
	    }
	}

Measured memory_bytes: 52624
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int count = 0;
        for(int i = 0; i < n; i++){
            long x = in.nextLong();
            long y  =in.nextLong();
            double p = Math.sqrt(x*x+y*y);
            if(p <= d){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 48960
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let t: i32 = read();
    let mut ans = 0;
    for i in 1..t + 1 {
        if i % a == 0 {
            ans += b;
        }
    }
    println!("{}", ans);
}


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

int main() {
  double N, K, x, sum;
  cin >> N >> K;
  sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < (K / 2)) {
      sum += x * 2;
    }
    else if (x < K) {
      sum += (K - x) * 2;
    }
    else {
      sum += (x - K) * 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
string s;
long long n;
vector<long long> dp(13);
int main()
{
	cin>>s;
	dp[0]=1;
	for(int i=0;i<s.size();i++)
	{
		vector<long long> d_n(13);
		for(int j=0;j<=9;j++)
		{
			if(s[i]=='?'||s[i]-'0'==j)
			{
				for(int k=0;k<13;k++)
				{
					d_n[(k*10+j)%13]+=dp[k]%md;
				}
			}
		}
		dp=d_n;
	}
	cout<<dp[5]%md;
	return 0;
}


Measured memory_bytes: 512
h,w=map(int,input().split())
x=[]
for i in range(1,w):
    x1=[h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]
    x2=[h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]
    x.append(min(max(x1)-min(x1),max(x2)-min(x2)))
for i in range(1,h):
    x1=[w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)]
    x2=[w*i,(h-i)*(w//2),w*(h-i)-(h-i)*(w//2)]
    x.append(min(max(x1)-min(x1),max(x2)-min(x2)))
print(min(x))


Measured memory_bytes: 10968
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func ReverseSequence(s []string) {
	defer fmt.Println()

	for i := 0; i < len(s); i++ {
		defer fmt.Print(s[i])
	}
}

func main() {
	sc.Scan()
	strs := strings.Split(sc.Text(), "")

	ReverseSequence(strs)
}



Measured memory_bytes: 1108
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>


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

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

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

N = int(input())
A = []
for i in range(2):
    a = [int(i) for i in input().split()]
    A.append(a)

max_drop_number = 0
for n in range(N):
    # 1行目
    first_drop_number = sum(A[0][:n+1])
    # 2行目
    second_drop_number = sum(A[1][n:])

    drop_number = first_drop_number + second_drop_number
    if drop_number > max_drop_number:
        max_drop_number = drop_number

print(max_drop_number)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), f(n+1);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    vector<bool> used(n+1, false);
    for(int i=0;i<n;i++){
        cin >> f[i];
        used[f[i]] = true;
    }
    bool ok = true;
    for(int i=1;i<=n;i++){
        ok &= used[i];
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
        for(int i=0;i<n;i++){
            cout << 1 << " \n"[i==n-1];
        }
        for(int i=0;i<n;i++){
            cout << (used[a[i]] ? 1 : 2) << " \n"[i==n-1];
        }
    }
    return 0;
}



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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000



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

	
	ll a, b, k;
	cin >> a >> b >> k;
	ll ab = __gcd(a, b);
	vl vet;
	for(ll i = 1; i * i <= ab; ++i){
		if(ab%i == 0){
			vet.push_back(i);
			if(i*i != ab){
				vet.push_back(ab/i);
			}
		}
	}
	sort(vet.begin(), vet.end());

	cout << vet[vet.size()-k] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1 + 300;
ld dp[N][N][N];

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

	int n;
	cin >> n;
	for (int c = 0; c <= n; ++c) {
		for (int b = 0; c+b <= n; ++b) {
			for (int a = 0; a+b+c <= n; ++a) {
				if (a == 0 && b == 0 && c == 0) continue;

				ld res = 0;
				if (a > 0) res += dp[a-1][b][c] * (ld)a / n;
				if (b > 0) res += dp[a+1][b-1][c] * (ld)b / n;
				if (c > 0) res += dp[a][b+1][c-1] * (ld)c / n;
				ld prob = (ld)(a+b+c) / n;
				res += 1;

				// dp[a][b][c] = 1 + res + (1 - prob) * dp[a][b][c];
				// dp[a][b][c] (1 - (1 - prob)) = 1 + res
				// dp[a][b][c] = (1 + res) / prob
				dp[a][b][c] = res / prob;
			}
		}
	}

	vector<int> cou(3, 0);
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		++cou[a-1];
	}
	cout << fixed << setprecision(20) << dp[cou[0]][cou[1]][cou[2]] << '\n';
}


Measured memory_bytes: 426240
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    string s;
    cin >> s;
    set<char>d;
    rep(i,s.size()) d.insert(s[i]);
    for(auto itr=d.begin(); itr !=d.end(); itr++){
        if (count(s.begin(), s.end(), *itr)%2 !=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

vector<int> G[100010];

int d[3][100010];
int V;
typedef pair<int, int> P;
typedef pair<int, P> PP;
void dijkstra(int s) {
    priority_queue<PP, vector<PP>, greater<PP>> que;
    d[0][s] = 0;
    que.push({0, {s, 0}});
    while (!que.empty()) {
        PP p = que.top(); que.pop();
        
        int v = p.second.first;
        int state = p.second.second;
        int next_state = (state + 1) % 3;
        if (d[state][v] < p.first) continue;
        //cerr << p.first << " " << p.second.first << " " << p.second.second << endl;
        for(auto to: G[v]) {
            //cerr << "*" << to << " " << d[next_state][to] << endl;
            if (d[next_state][to] > d[state][v] + 1) {
                d[next_state][to] = d[state][v] + 1;
                que.push({d[next_state][to], {to, next_state}});
            }
        }
    }
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    V = N;
    cin >> N >> M;
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        //G[v].push_back(u);
    }
    rep(i, 3) rep(j, 100010) d[i][j] = INF;
    int S, T; cin >> S >> T;
    S--; T--;
    dijkstra(S);
    if(d[0][T] == INF) {
        cout << "-1" << endl;
    } else {
        cout << d[0][T]/3 << endl;
    }

    return 0;
}


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

int main(){
	int a, b, c, N;

	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> a >> b >> c; 
		if(a*a + b*b == c*c || a*a + c*c == b*b || b*b + c*c == a*a){
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt();
        int m= sc.nextInt();
        if( m<=n ){
            System.out.println(0);
            return;
        }
        List<Integer> xi = new ArrayList<Integer>(m){{
            for( int i=0; i<m; i++){ add(sc.nextInt()); }
        }}; xi.sort(Comparator.comparingInt(x->x));
        //
        List<Integer> dist = new ArrayList<Integer>(m-1){{
            int prev= xi.get(0);
            for( int i=1; i<m; i++) {
                int now = xi.get(i);
                add( now - prev );
                prev= now;
            }
        }}; dist.sort(Comparator.comparingInt(x->x));
        int tot= 0;
        for( int i=0; i<m-n; i++) {
            tot += dist.get(i);
        }
        System.out.println(tot);
    }
}


Measured memory_bytes: 61568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,b,c;
    int a[100010];
    long long ans;
    bool flag1,flag2;
    cin>>n;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    flag1=flag2=false;
    for(i=n-1;i>=1;i--)
    {
        if (a[i]==a[i+1])
        {
            if (!flag1)
            {
                flag1=true;
                b=a[i];i--;
            }
            else
                if (!flag2)
                {
                    flag2=true;
                    c=a[i];
                    break;
                }
        }
    }
    ans=(long long)b*c;
    if (flag2) cout<<ans<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  ll ans=0;
  int sum=0,r=0;
  REP(l,n) {
    while(r < n) {
      if ((sum^a[r]) != (sum+a[r])) break;
      sum += a[r];
      r++;
    }
    ans += r - l;

    if (r == l) r++;
    else sum -= a[l];
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 3976
import java.text.MessageFormat;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		double x1 = scanner.nextDouble();
		double y1 = scanner.nextDouble();
		double x2 = scanner.nextDouble();
		double y2 = scanner.nextDouble();
		double x;
		double y;
		double c;
		double c2;
		if (x1 > x2) {
			x = x1 - x2;
		} else {
			x = x2 - x1;
		}
		if (y1 > y2) {
			y = y1 - y2;
		} else {
			y = y2 - y1;
		}
		c2 = x * x + y * y;
		c = Math.sqrt(c2);
		System.out.println(MessageFormat.format("{0,number,0.00000000} ", c));
		scanner.close();
	}
}



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

using namespace std;

int main() {
	
	
	       
    long long int n;
    cin>>n;
    long long int a[n],i,cnt=0,j,k;
    for(i=0;i<n;++i)
        cin>>a[i];
        
    sort(a,a+n);
    
    for(i=0;i<n;++i)
      {
          for(j=i+1;j<n;++j)
           {
               for(k=j+1;k<n;++k)
                {
                    if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k])
                       cnt++;
                }
           }
      }
      
      cout<<cnt;
	
	
	
	return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
	
//	public static String rev(int s) {
//		 String rev = new StringBuffer(s).reverse().toString();
//		 return rev;
//	}
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
        int a = sc.nextInt();
        
        	
        	
        	
        	System.out.println(a+a*a+a*a*a);
        }
         
        
        
        
	
}



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


/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
*/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) � To sort the given vector.

reverse(first_iterator, last_iterator) � To reverse a vector.

*max_element (first_iterator, last_iterator) � To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) � To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) � Does the summation of vector elements

count(first_iterator, last_iterator,x) � To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) � Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) � Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) � returns an iterator pointing to the first element in the range [first,last)
which has a value not less than �x�.

upper_bound(first_iterator, last_iterator, x) � returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than �x�.

arr.erase(position to be deleted) � This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) � This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) � It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) � This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) � This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{

    ll a,b;
    cin>>a>>b;
   if(a!=1&&b!=1)
    cout<<1<<endl;
   else if(a!=2&&b!=2)
    cout<<2<<endl;
   else if(a!=3 &&b!=3)
    cout<<3<<endl;



    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, k, a[105], dp[105][100005], mod=1000000007;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k; dp[0][0]=1;
for (int i=1; i<=n; i++) cin >> a[i];
for (int i=1; i<=n; i++){
	long long sum=0;
	for (int j=0; j<=k; j++){
		sum+=dp[i-1][j];
		if (j>a[i]) sum-=dp[i-1][j-a[i]-1];
		sum = ((sum%mod)+mod)%mod;
		dp[i][j]=sum;
	}
} cout << dp[n][k];
return 0;
}


Measured memory_bytes: 81684
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,ans=0;cin>>n;
   for(ll i=1;i<=n;i++)
   {
       if(i%3!=0 && i%5!=0)
        ans+=i;

   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3620
# N, A, B = gets.split(" ").map(&:to_i)
# S = gets.chomp
N = gets.to_i

ans = 0
case
when N >= 100000
  ans = (100000 - 10000) + (1000 - 100) + (10 - 1)
when N >= 10000
  ans = (N + 1 - 10000) + (1000 - 100) + (10 - 1)
when N >= 1000
  ans = (1000 - 100) + (10 - 1)
when N >= 100
  ans = (N + 1 - 100) + (10 - 1)
when N >= 10
  ans = (10 - 1)
when N >= 1
  ans = N - 1 + 1
end
puts ans


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

int main()
{
	int n, t, a = 0;
	cin >> n;
	cin >> t >> a;
	double min = 9999;
	double x = 0;
	int res =1;
	for(int i = 0; i < n; i++)
	{
		double h = 0;
		cin >> h;

		x = fabs(a - (t - h * 0.006));
		if (x < min)
		{
			min = x;
			res = i + 1;
		}
	}

	cout << res << "\n";

	return 0;
}

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

int n,spot[100002],total,kurang,a,b;

int main(){
	scanf("%d",&n);
	total=0;
	spot[0]=0;
	spot[n+1]=0;
	for(int i=1 ; i<=n ; i++){
		scanf("%d",&spot[i]);
		total += abs(spot[i]-spot[i-1]);
		if(i==n) total+=abs(spot[i]);
	}
	for(int i=1; i<=n ; i++){
		a = spot[i]-spot[i-1];
		b = spot[i+1]-spot[i];
		if( a*b >= 0) printf("%d\n",total);
		else printf("%d\n",total - 2 * min(abs(a),abs(b)));
	}
	return 0;
}

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

inline void solve(){ 
    map <int,int> cnt;
    int n; cin>>n; 
    while (n--){
        int a; cin>>a;
        cnt[a]++;
    }
    int c=0;
    for (auto &it: cnt) c += it.ss-1; 
    int  ans = sz(cnt); 
    if (c&1) ans--;
    cout << ans << endl;
}

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


Measured memory_bytes: 9660
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }

    let mut a = a;
    let mut b = b;
    let mut c = c;
    let mut d = d;

    let mut res = "Yes";
    loop {
        c -= b;
        if c <= 0 {
            res = "Yes";
            break;
        }

        a -= d;
        if a <= 0 {
            res = "No";
            break;
        }
    }
    println!("{}", res);

}


Measured memory_bytes: 2160
#include<cstdio>
using namespace std;
#define MAX 1000000
int prime[MAX];
bool is_prime[MAX];
int sieve(int n){   //埃氏?
   int p=0;
   for(int i=0;i<=n;i++)
    is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
   for(int i=2;i<=n;i++){
    if(is_prime[i]){
        prime[p++]=i;    //??素数的个数和素数的?
        for(int j=2*i;j<=n;j+=i)
            is_prime[j]=false;
    }
   }
   return p;
}
int main()
{
  int num;
  while(scanf("%d",&num)!=EOF){
   printf("%d\n",sieve(num));
  }
  return 0;
}

Measured memory_bytes: 3860
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    ll r,d,x;
    cin >> r >> d >> x;
    for(int i=0; i<10; i++){
        x=r*x-d;
        cout << x << endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;

        static void Solve()
        {
            int n = ReadAndParseInt();
            int h = ReadAndParseInt();
            int w = ReadAndParseInt();
            int ans = (n - h + 1) * (n - w + 1);
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

using namespace std;

#define i64 long long
#define endl "\n"
#define maxn 100005
#define mod 1000000007

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

    i64 n, m, ans = 0;
    cin >> n >> m;
    ans += min(n, (m / 2)), n -= ans, m -= ans * 2;
    if(!n)
        ans += m / 4;

    cout << ans << endl;

    /*cin.clear();
    cin.ignore();
    cin.get();*/
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    
    double x1,x2,y1,y2,x,y,ans,xx,yy;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    x = fabs(x2-x1);
    y = fabs(y2-y1);
    
    ans = sqrt(pow(x,2) + pow(y,2));
    
    printf("%.8f", ans);
    
    return 0;
    
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

vector<ll> bars(int w,int twos,int W) {
	vector<ll> res(3);
	for (int i = 0; i < twos; i++) {
		int temp = i;
		vector<int> bit(W-1);
		for (int j = 0; temp > 0; j++) {
			bit[j] = temp % 2;
			temp /= 2;
		}
		bool flag = true;
		for (int k = 0; k < W-2; k++) {
			if (bit[k] == 1 && bit[k + 1]==1) {
				flag = false;
				break;
			}
		}
		//cout << "bit finished" << endl;
		if (flag) {
			//cout << "w=" << w << endl;
			if (w == W) {
				//cout << "w-2=" << w - 2 << endl;
				if (bit[w - 2] == 1) res[0]++;
				if (bit[w - 2] == 0) res[1]++;
				
			}
			else if (w == 1) {
				if (bit[w - 1] == 1) res[2]++;
				if (bit[w - 1] == 0) res[1]++;
			}
			else {
				if (bit[w - 2] == 1) res[0]++;
				else if (bit[w - 1] == 1) res[2]++;
				else  res[1]++;
			}
		}

	}

	return res;
}
int main() {
	int H, W, K; cin >> H >> W >> K;
	if (W == 1) cout << 1 << endl;
	else {
		vector<vector<ll>> dp(H + 1, vector<ll>(W + 1));
		dp[0][1] = 1;
		int twos = pow(2, W - 1);
		for (int i = 0; i < H; i++) {
			for (int j = 1; j <= W; j++) {
				//cout << "yahoo" << endl;
				vector<ll> cnt = bars(j, twos, W);
				dp[i + 1][j] += (cnt[1] * dp[i][j]) % DIV;
				dp[i + 1][j] %= DIV;
				if (j - 1 >= 1) {
					dp[i + 1][j - 1] += (cnt[0] * dp[i][j]) % DIV;
					dp[i + 1][j - 1] %= DIV;
				}
				if (j + 1 <= W) {
					dp[i + 1][j + 1] += (cnt[2] * dp[i][j]) % DIV;
					dp[i + 1][j + 1] %= DIV;
				}
			}
		}
		cout << dp[H][K] << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

vvl e(200005);
vl dp(200005);
vl nd(200005);
ll n;
vl fact,finv;
ll modpw(ll x,ll k){
	ll res=1;
	while(k!=0){
		if(k&1)res=res*x%MOD;
		x=x*x%MOD;
		k=k>>1;
	}
	return res;
}

ll comb(ll n,ll k) {
	if(n==0&&k==0)return 1;
	if(n<k||n<0)return 0;
	return fact[n]*finv[n-k]%MOD*finv[k]%MOD;
}

struct ferm{
	ferm(ll n){
		fact.resize(n);
		finv.resize(n);
		fact[0]=1;
		finv[0]=1;
		rep(i,n-1){
			fact[i+1]=(fact[i]*(i+1))%MOD;
			finv[i+1]=modpw(fact[i+1],MOD-2);
		}
	}
};
void dfs1(ll cur,ll pre){
	nd[cur]=0;
	dp[cur]=1;
	for(auto x:e[cur]){
		if(pre==x)continue;
		dfs1(x,cur);
		(dp[cur]*=dp[x])%=MOD;
		(dp[cur]*=comb(nd[cur]+nd[x],nd[x]))%=MOD;
		nd[cur]+=nd[x];
	}
	nd[cur]++;
}
void dfs2(ll cur,ll pre,ll bt){
	(dp[cur]*=bt)%=MOD;
	(dp[cur]*=comb(n-1,nd[cur]-1))%=MOD;
	for(auto x:e[cur]){
		if(pre==x)continue;
		bt=(dp[cur]*modpw((comb(n-1,nd[x])*dp[x])%MOD,MOD-2))%MOD;
		dfs2(x,cur,bt);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	ferm(200005);
	ll a,b;
	rep(i,n-1){
		cin>>a>>b;a--;b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs1(0,0);
	dfs2(0,0,1);
	rep(i,n)puta(dp[i]);
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;
const double EPS=1e-12;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll A[N];
  for(ll i=0;i<N;i++){
    cin>>A[i];
  }
  ll ans=0;
  for(ll i=0;i<N;i++){
    ans -= A[i]*(2*(i&1)-1);
  }
  for(ll i=0;i<N;i++){
    cout<<ans<<endl;
    ans = -ans+2*A[i];
  }
  return 0;
}


Measured memory_bytes: 2176
import itertools
import itertools

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

ans = 0
for l1, l2, l3 in itertools.combinations(L, 3):
    if l1 == l2 or l2 == l3:
        continue
    
    if l3 < l1 + l2:
        ans += 1

print(ans)

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

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

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

    int a, b;
    cin >> a >> b;
    if (b >= a) {
        cout << a << "\n";
    } else {
        cout << a - 1 << "\n";
    }


}















Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int inf=0xfffffff;
struct edge{
  int to,cap,cost,rev;
};
int v;
vector<edge> G[105];
int dist[105],prevv[105],preve[105];
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,(int)G[to].size()});
  G[to].push_back((edge){from,0,-1*cost,(int)G[from].size()-1});
}
int min_cost_flow(int s,int t,int f){
  int res=0;
  while(f>0){
    for(int i=0;i<105;i++) dist[i]=inf;
    dist[0]=0;
    bool update=true;
    while(update){
      update=false;
      for(int i=0;i<v;i++){
        if(dist[i]>=inf) continue;
        for(int j=0;j<G[i].size();j++){
          edge &e=G[i][j];
          if(e.cap>0&&dist[e.to]>dist[i]+e.cost){
            dist[e.to]=dist[i]+e.cost;
            prevv[e.to]=i;
            preve[e.to]=j;
            update=true;
          }
        }
      }
    }
    if(dist[t]>=inf) return -1;
    int d=f;
    for(int i=t;i!=s;i=prevv[i]){
      d=min(d,G[prevv[i]][preve[i]].cap);
      //cout<<preve[i]<<" ";
    }
    //cout<<endl;
    f-=d;
    res+=dist[t]*d;
    //cout<<"d:"<<d<<" route:";
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      //cout<<prevv[v]<<" ";
      e.cap-=d;
      G[v][e.rev].cap+=d;
    }
    //cout<<endl;

  }
  return res;
}
int main(){
  int e,f;
  cin>>v>>e>>f;
  for(int i=0;i<e;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    add_edge(a,b,c,d);
  }
  cout<<min_cost_flow(0,v-1,f)<<endl;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#pragma GCC optimize(3)
#pragma GCC optimize("02")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
class complex{
public:
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline complex & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
bool vis[10];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x;
	int cnt=0;
	for(register int i=1;i<=3;i++){
		inc>>x;
		if(!vis[x]) cnt++,vis[x]=true;
	}
	puts(cnt==2?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N,C;
    cin>>N>>C;
    vector<vector<bool>> v(30,vector<bool>(100001,false));
    int s,t,c;
    int res=0;
    REP(i,N){
        cin>>s>>t>>c;c--;
        FOR(j,s-1,t)v[c][j]=true;
    }
    REP(i,100001){
        int cnt=0;
        REP(j,30){
            if(v[j][i])cnt++;
        }
        res=max(res,cnt);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
#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;}
int digisum(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}  //  桁和
int stpow(int n){if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
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;}
vector<pair<int,int>> fac(int n) {  //  素因数分解
vector<Pii>r;for(int i=2;i*i<=n;++i){if(n%i)continue;r.emplace_back(i,0);while(n%i==0){
n/=i;r.back().second++;}}if(n!=1)r.emplace_back(n,1);return r;}
bool prime(int n){  //  素数判定
if(n<2)return false;else if(n==2)return true;else if(n%2==0)return false;
double s=sqrt(n);for(int i=3;i<=s;i+=2){if(n%i==0){return false;}}return true;}
Vi primevec(){  //  素数配列
int N=1000000;int l[N];Vi a(0);for(int i=0;i<N;i++){l[i]=1;}for(int i=2;i<sqrt(N);i++){
if(l[i]){for(int j=0;i*(j+2)<N;j++){l[i*(j+2)]=0;}}}for(int i=2;i<N;i++){if(l[i]){
a.pb(i);}}return a;}
int comb(int n, int r){  //  nCr (MOD環境下)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,ans=0;
  cin >> n;
  Vi a(n);
  Vin(a);
  
  sortr(ALL(a));
  
  rep(i,0,n){
    rep(j,i+1,n){
      rep(k,j+1,n){
        if(a[i] < a[j]+a[k]) ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

struct Team {

  int teamID;
  int n_accepted;
  int penalty;

  bool operator <(const Team &t) const {
    if(n_accepted != t.n_accepted)
      return n_accepted > t.n_accepted;
    if(penalty != t.penalty)
      return penalty < t.penalty;
    return teamID < t.teamID;
  }

};

int main() {
  int T, P, R;
  while(cin >> T >> P >> R && (T|P|R)) {
    vector<Team> v(T);
    vector< vector<int> > n_wrong( T, vector<int>(P, 0) );
    for(int i = 0; i < T; ++i) {
      v[i].teamID = i;
      v[i].n_accepted = 0;
      v[i].penalty = 0;
    }

    while(R--) {
      int tID, pID, time;
      string message;
      cin >> tID >> pID >> time >> message;
      --tID; --pID;
      if(message[0] == 'C') {
        v[tID].n_accepted += 1;
        v[tID].penalty += n_wrong[tID][pID] * 1200 + time;
      } else {
        n_wrong[tID][pID] += 1;
      }
    }

    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); ++i) {
      cout << v[i].teamID+1 << " "
           << v[i].n_accepted << " "
           << v[i].penalty << endl;
    }

  }
  return 0;
}

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

int main() {
	int X;
	cin >> X;
	cout << X / 500 * 1000 + X % 500 / 5 * 5 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int m,d,cnt=0;
	scanf("%d%d",&m,&d);
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++) {
			int d1=j/10,d2=j%10;
			if(d1<2 || d2<2) continue;
			if(d1*d2==i) cnt++;
		}
	printf("%d",cnt);
	return 0;
} 

Measured memory_bytes: 384