akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef pair<int,int> pi;
vector<pi>adj[104];
bool mark[104][104];
bool temp[104][105];
int par[105];
//vector<int>par[104];
int dis[104];
#define inf 1000000
int s_p(int st,int ed)
{
    par[st]=-1;
    for(int i=0;i<103;i++)dis[i]=inf;
    priority_queue<pi,vector<pi>,greater<pi>>q;
    q.push({0,st});
    dis[st]=0;
    while(!q.empty())
    {
        int top=q.top().second;
        int cost=q.top().first;
        q.pop();
        if(top==ed)break;
        for(int i=0;i<adj[top].size();i++)
        {
            int chi=adj[top][i].second;
            int cst=adj[top][i].first;
            if(cost+cst<=dis[chi]&&temp[top][chi]==0)
            {
                dis[chi]=cost+cst;
                q.push({dis[chi],chi});
                par[chi]=top;
            }
        }
    }
    return dis[ed];
}
bool vis[104];
void path(int ed)
{
    while(par[ed]!=-1)
    {
        int x=par[ed];
        mark[x][ed]=1;
        mark[ed][x]=1;
        temp[x][ed]=1;
        temp[ed][x]=1;
//        cout<<ed<<" par "<<x<<endl;
        ed=par[ed];

    }
}
int main()
{
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v,w;cin>>u>>v>>w;
        adj[u].pb({w,v});
        adj[v].pb({w,u});
    }
    int cnt=0;
    for(int i=1;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
//            cout<<"calling from "<<i<<" "<<j<<endl;
            memset(temp,0,sizeof temp);
            int val=s_p(i,j);
            path(j);
            while(s_p(i,j)==val)
            {
                path(j);
            }
        }
    }
    for(int i=1;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(mark[i][j])cnt++;
        }
    }
    cout<<m-cnt<<endl;
}
/*

4 5
1 2 4
1 4 3
2 3 3
2 4 1
3 4 4

*/



Measured memory_bytes: 384
import java.util.Scanner

object Main {
  def i18n(str: String): String = {
    return str.head.toString + (str.length-2).toString + str.last.toString
  }
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.next()
    val ans = i18n(s)
    println(ans)
  }
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

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

  ll ans = 0;
  rep(i, n) {
    ans += a[i] / 2;
    a[i] %= 2;
    if (i != n - 1 && a[i] == 1 && a[i + 1] >= 1) {
      a[i]--;
      a[i + 1]--;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3792
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 4;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<long long> > jewel(m);
    for(int i=0; i<n; ++i){
        int col, val;
        cin >> col >> val;
        -- col;
        jewel[col].push_back(val);
    }

    multiset<long long> ms2 = {-INF};
    multiset<long long> ms3 = {-INF};
    vector<pair<long long, int> > v;
    for(int col=0; col<m; ++col){
        sort(jewel[col].rbegin(), jewel[col].rend());
        jewel[col][0] = jewel[col][1] = jewel[col][0] + jewel[col][1];
        for(unsigned i=2; i<jewel[col].size(); ++i)
            jewel[col][i] *= 2;
        for(unsigned i=0; i<jewel[col].size(); ++i)
            v.push_back(make_pair(jewel[col][i], col));
        ms2.insert(jewel[col][0] + jewel[col][1]);
        if(jewel[col].size() >= 3)
            ms3.insert(jewel[col][0] + jewel[col][1] + jewel[col][2]);
    }
    sort(v.rbegin(), v.rend());
    
    multiset<long long> ms1 = {-INF};
    vector<int> cnt(m, 0);
    long long sum = 0;
    long long minVal1 = INF;
    long long minVal2 = INF;
    for(int i=0; i<n; ++i){
        long long val;
        int col;
        tie(val, col) = v[i];

        long long ans = -1;
        if(cnt[col] == 0){
            ans = max(ans, (sum + *ms1.rbegin()) / 2);
            ans = max(ans, (sum - minVal1 + *ms2.rbegin()) / 2);
            ans = max(ans, (sum - minVal2 + *ms3.rbegin()) / 2);

            for(unsigned i=1; i<jewel[col].size(); ++i)
                ms1.insert(jewel[col][i]);
            ms2.erase(ms2.find(jewel[col][0] + jewel[col][1]));
            if(jewel[col].size() >= 3)
                ms3.erase(ms3.find(jewel[col][0] + jewel[col][1] + jewel[col][2]));
        }
        else{
            ans = (sum + val) / 2;
            ms1.erase(ms1.find(val));
            if(cnt[col] == 1)
                minVal2 = min(minVal2, val * 2);
            else
                minVal1 = min(minVal1, val);
        }

        cout << ans << endl;
        ++ cnt[col];
        sum += val;
    }

    return 0;
}


Measured memory_bytes: 18028
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
//using nint=System.Int32;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		while(s[0]+s[1]!=0){
			int ans=0;
			for(int i = 1;i<s[0]-1;i++) {
				for(int j = i+1;j<s[0];j++) {
					if(s[1]-i-j<=s[0]&&j<s[1]-i-j){ans++;}
				}
			}
			Console.WriteLine("{0}",ans);
			s=sc.Ia;
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main(void){

  long long int a, b, c, tmp;
  
  scanf("%lld %lld", &a, &b);
  if(a < b){
    tmp=a;
    a=b;
    b=tmp;
  }
  c = a%b;
  
  while(c != 0){
    a=b;
    b=c;
    c=a%b;
  }

  printf("%d\n", b);
  
  return 0;
}



Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		for(int i=0;i<9;i++){
			String name = stdIn.next();
			int am = stdIn.nextInt();
			int pm = stdIn.nextInt();
			int total = am+pm;
			int money = am*200+pm*300;
			System.out.println(name+" "+total+" "+money);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>

using namespace std;

int main()
{
    long long x;
    cin>>x;
    long long sum=0;
    sum=(1+x)*x/2;
    for(long long int i=1;i<=x;i++)
    {
        if(i%3==0||i%5==0)
        {
           sum-=i;
        }
    }
    cout<<sum;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n]={0},c[200005]={0};
    for(int i=1;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
        c[a[i]]++;
    for(int i=0;i<n;i++)cout<<c[i+1]<<endl;
    return 0;
}


Measured memory_bytes: 5200
#include <stdio.h>
#include <algorithm>
#include <vector>
#define MAXN 100001
#define iPair pair<int, int>
using namespace std;
vector <iPair> x(MAXN);
vector <iPair> y(MAXN);
struct Graph {
	int V, E;
	vector <pair <int, iPair> > edges;
	Graph(int V, int E) {
		this->V = V;
		this->E = E;

	}
	void addEdge(int src, int dest, int w) {
		edges.push_back(make_pair(w, make_pair(src, dest)));
	}
	int kruskal();

};
struct DisjointSets {
	int *parent, *rnk;
	int n;
	DisjointSets(int n){
		this->n = n;
		parent = new int[n + 1];
		rnk = new int[n + 1];
		for (int i = 0; i <= n; i++) {
			rnk[i] = 0;
			parent[i] = i;
		}
	}
	int find(int u) {
		if (u != parent[u]) {
			parent[u] = find(parent[u]);
		}
		return parent[u];
	}
	void merge(int x, int y) {
		x = find(x);
		y = find(y);
		if (rnk[x] > rnk[y]) {
			parent[y] = x;
		}
		else {
			parent[x] = y;
		}
		if (rnk[x] == rnk[y]) {
			rnk[y]++;
		}
	}
};
int Graph::kruskal() {
	int mst_wt = 0;
	sort(edges.begin(), edges.end());
	DisjointSets ds(V);
	vector< pair<int, iPair> >::iterator it;
	for (it = edges.begin(); it != edges.end(); it++) {
		int u = it->second.first;
		int v = it->second.second;
		int set_u = ds.find(u);
		int set_v = ds.find(v);
		if (set_u != set_v) {
			mst_wt += it->first;
			ds.merge(set_u, set_v);
		}
	}
	return mst_wt;
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int xt, yt;
		scanf("%d%d",&xt,&yt);
		x[i] = make_pair(xt, i);
		y[i] = make_pair(yt, i);

	}
	sort(x.begin(), x.begin()+n);
	sort(y.begin(), y.begin()+n);
	int V = n;
	int E = 2 * n - 2;
	Graph graph(V, E);
	for (int i = 0; i < V - 1; i++) {
		graph.addEdge(x[i].second, x[i+1].second, x[i+1].first-x[i].first);
		graph.addEdge(y[i].second, y[i + 1].second, y[i + 1].first - y[i].first);
	}
	printf("%d", graph.kruskal());
	return 0;
	
}

Measured memory_bytes: 6516
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
    if a[i+1]-a[i]==1:
        ans+=c[a[i]-1]
print(ans)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll H,W,A[88][88],B[88][88],AB[88][88];
bool dp[88][88][20202];
ll i, j, k,ans;


ll idx(ll a){
    return (a + 20000) % 20000;
}

int main(){
    scanf("%lld%lld", &H,&W);
    fornum(i,0,H){
        fornum(j,0,W){
            scanf("%lld", &A[i][j]);
        }
    }
    fornum(i,0,H){
        fornum(j,0,W){
            scanf("%lld", &B[i][j]);
        }
    }
    fornum(i,0,H){
        fornum(j,0,W){
            AB[i][j] = abs(A[i][j] - B[i][j]);
        }
    }
    dp[0][0][0] = true;
    fornum(i,0,H){
        fornum(j,0,W){
            fornum(k,0,20000){
                if(!dp[i][j][k])
                    continue;
                //printf("%lld,%lld:%lld ", i, j, k);
                dp[i + 1][j][idx(k + AB[i][j])] = true;
                dp[i + 1][j][idx(k - AB[i][j])] = true;
                dp[i][j + 1][idx(k + AB[i][j])] = true;
                dp[i][j + 1][idx(k - AB[i][j])] = true;
            }
        }
    }
    fornum(i,0,20000){
        if(dp[H-1][W][i])
            break;
    }
    printf("%lld", i);

    return 0;
}

Measured memory_bytes: 140672
import java.io.*;
import java.util.*;


// 2011/10/23

// 0139 Snakes
public class Main {

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		String s = reader.readLine();
		
		String type = "NA";
		
		String regA = ">'(=+)#(=+)\\~";
		
		if (s.matches(regA)) {
			if (s.replaceAll(regA, "$1").equals(s.replaceAll(regA, "$2")))
				type = "A";
		}
		else if (s.matches(">\\^(Q=)+\\~\\~")) {
			type = "B";
		}
		
		System.out.printf("%s\n", type);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "1:>'======#======~:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 13000
# -*- coding: utf-8 -*-
tmp = []
n = 0
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    else:
        x = min(a, b)
        y = max(a, b)
        tmp.append([x, y])
        n += 1

for i in range(n):
    print(tmp[i][0], tmp[i][1])



Measured memory_bytes: 6248
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for _ in range(N):
    a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((a,b,c))

dp = [[0]*3 for _ in range(N)]
dp[0][0] = data[0][0]
dp[0][1] = data[0][1]
dp[0][2] = data[0][2]

for i in range(1,N):
    dp[i][0] = data[i][0] + max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = data[i][1] + max(dp[i-1][0],dp[i-1][2])
    dp[i][2] = data[i][2] + max(dp[i-1][0],dp[i-1][1])
print(max(dp[-1]))

Measured memory_bytes: 40224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int N;
vector<vector<int>> G;

void dfs(int u,int p,vector<int> &dist){
    for(int v : G[u]){
        if(v == p) continue;
        dist[v] = dist[u]+1;
        dfs(v,u,dist);
    }
}

int main(){
    cin >> N;
    G.resize(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist1(N);
    vector<int> dist2(N);
    dfs(0,-1,dist1);
    dfs(N-1,-1,dist2);

    int cnt = 0;

    repr(i,1,N-1){
        if(dist1[i] <= dist2[i]){
            cnt++;
        }
    }
    int cnt2 = N-2-cnt;
    if(cnt > cnt2){
        cout << "Fennec" << endl;
    }
    else if(cnt < cnt2){
        cout << "Snuke" << endl;
    }
    else{
        if(N % 2 == 0){
            cout << "Snuke" << endl;
        }
        else{
            cout << "Fennec" << endl;
        }
    }
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

typedef long double ld;

struct Vec {
	int x, y;

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

	Vec(int x_, int y_) {
		x = x_;
		y = y_;
	}

	Vec norm() const {
		return Vec(-y, x);
	}

	int operator%(const Vec &other) const {
		return x * other.x + y * other.y;
	}

	int operator*(const Vec &other) const {
		return x * other.y - y * other.y;
	}

	Vec operator+(const Vec &other) const {
		return Vec(x + other.x, y + other.y);
	}

	ld len() {
		return hypot((ld)x, (ld)y);
	}
};

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

	int n;
	cin >> n;
	vector<Vec> a(n);
	for (auto &t : a) {
		cin >> t.x >> t.y;
	}
	vector<Vec> v;
	for (int i = 0; i < n; i++) {
		Vec cur = a[i];
		for (int j = 0; j < 4; j++) {
			v.push_back(cur);
			cur = cur.norm();
		}
	}
	ld ans = 0;
	for (auto vc : v) {
		Vec cur;
		Vec f, s;
		for (auto t : a) {
			if ((vc % t) > 0) {
				cur = cur + t;
			} else if (vc % t == 0) {
				if (vc * t > 0) f = f + t;
				else s = s + t;
			} 
		}
		ans = max(ans, cur.len());
		{
			Vec c = cur + f;
			ans = max(ans, c.len());
		}
		{
			Vec c = cur + s;
			ans = max(ans, c.len());
		}
	}
	cout << fixed << setprecision(16);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private static boolean binarySearch(int[] a, int st, int ed, int k) {
		if (st == ed - 1) {
			return a[st] == k;
		}

		int idx = (ed - st) / 2 + st;
		int m = a[idx];

		if (m == k) {
			return true;
		} else if (m > k) {
			return binarySearch(a, st, idx, k);
		} else if (m < k) {
			return binarySearch(a, idx, ed, k);
		}

		return false; // 到達しない

	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int[] S = nextIntArray(sc, n);

		int q = sc.nextInt();
		int[] T = nextIntArray(sc, q);

		sc.close();

		int ans = 0;

		for (int i = 0; i < q; i++) {
			if (binarySearch(S, 0, n, T[i])) {
				ans++;
			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}



Measured memory_bytes: 67256
#!/usr/bin/env ruby



$visited = []
$pre_vertex = []


def min a,b
  if a<b then return a else b end
end

def init_dfs v,e
  $visited = Array.new(v,false)
  $pre_vertex = Array.new(v,false)
end

#b -> e ??§edges
def dfs b,e,es
  es[b].each_with_index do |c,v|
    if !$visited[v] and c>0 then
      $visited[v] = true
      $pre_vertex[v] = b
      dfs(v,e,es)
    end
  end
end


def back_trace v,e,es
  flow =[]
  min_c = 10e8

  to = v-1
  from = $pre_vertex[v-1]
  flow=[[from,to]]+flow
  min_c = min(min_c,es[from][to])

  while from != 0
    to = from
    from = $pre_vertex[from]
    flow=[[from,to]]+flow
    min_c = min(min_c,es[from][to])
  end
  return flow,min_c
end



v_size,e_size = gets.chomp.split(/ /).map{|i| i.to_i}

edges = Array.new(v_size).map{ Array.new(v_size,0)}


e_size.times do
  u,v,c = gets.chomp.split(/ /).map{|i| i.to_i}
  edges[u][v]=c
end

  @ans = 0
loop do
  init_dfs(v_size,e_size)
  dfs(0,v_size-1,edges)
  if $visited[v_size-1] then
    f,min_c = back_trace(v_size,e_size,edges)
    f.each do |i|
      edges[i[0]][i[1]]-=min_c
      edges[i[1]][i[0]]+=min_c
    end
    @ans = @ans+ min_c
  else
    p @ans
    break
  end
end

Measured memory_bytes: 10484
#include <iostream>
#include <vector>
#include <string>
#define input std::cin

using lint = long long int;
using namespace std;

int modulo = 998244353;

int power(int x, unsigned int y, int p) {
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        if (y & 1)
            res = (res*(lint)x) % p;
        y = y>>1; // y = y/2
        x = (x*(lint)x) % p;
    }
    return res;
}

class segtree {
  public:
	vector<int> tree;
	vector<int> ptree;
	vector<int> p10;
	int n;
	segtree (int n) : tree (4*n+1, 0), ptree (4*n+1, -1), p10(n), n (n) {
	  p10[0] = 1;
	  int p = 10;
	  for (int i=1; i<n; i++) {
		p10[i] = (p10[i-1] + (lint) p) % modulo;
		p = (p * (lint) 10) % modulo;
	  }
	  update (0, n-1, 1);
	}

	int query (int l, int r, int tl, int tr, int t) {
	  if (l > r)
		return 0;
	  if (l == tl && r == tr)
		return tree[t];
	  int mid = (tl+tr)/2;
	  if (ptree[t] != -1) {
		update (tl, mid, ptree[t], tl, mid, 2*t+1);
		update (mid+1, tr, ptree[t], mid+1, tr, 2*t+2);
		ptree[t] = -1;
	  }
	  int left = query (l, min(mid, r), tl, mid, 2*t+1);
	  int right = query (max(mid+1,l), r, mid+1, tr, 2*t+2);
	  int pow10 = power (10, tr-mid, modulo);
	  return ((left * (lint)pow10) % modulo + (lint) right) % modulo;
	}

	int query (int l, int r) {
	  return query (l, r, 0, n-1, 0);
	}

	void set (int i, int v, int tl, int tr, int t) {
	  if (i < tl || i > tr)
		return;
	  if (tl == tr) {
		tree[t] = v;
		return;
	  }
	  int mid = (tl+tr)/2;
	  set (i, v, tl, mid, 2*t+1);
	  set (i, v, mid+1, tr, 2*t+2);
	  int left = tree[2*t+1], right = tree[2*t+2];
	  int pow10 = power (10, tr-mid, modulo);
	  tree[t] = ((left * (lint)pow10) % modulo + (lint) right) % modulo;
	}

	void set (int i, int v) {
	  set (i, v, 0, n-1, 0);
	}

	void update (int l, int r, int v, int tl, int tr, int t) {
	  if (l < tl || r > tr)
		return;
	  if (l > r)
		return;
	  /* std::cout << l << " " << r << std::endl; */
	  if (l == tl && r == tr) {
		tree[t] = (v * (lint) p10[tr-tl]) % modulo;
		ptree[t] = v;
		return;
	  }
	  int mid = (tl+tr)/2;
	  if (ptree[t] != -1) {
		update (tl, mid, ptree[t], tl, mid, 2*t+1);
		update (mid+1, tr, ptree[t], mid+1, tr, 2*t+2);
		ptree[t] = -1;
	  }
	  update (l, min(r, mid), v, tl, mid, 2*t+1);
	  update (max(l, mid+1), r, v, mid+1, tr, 2*t+2);
	  int left = tree[2*t+1], right = tree[2*t+2];
	  int pow10 = power (10, tr-mid, modulo);
	  tree[t] = ((left * (lint)pow10) % modulo + (lint) right) % modulo;
	}

	void update (int l, int r, int v) {
	  update (l, r, v, 0, n-1, 0);
	}
};

int main() {
  std::ios_base::sync_with_stdio(0);
  int n, q; input >> n >> q;
  segtree number (n);
  /* std::cout << number.query(0,n-1) << std::endl; */
  for (int i=0; i<q; i++) {
	int l, r, v; input >> l >> r >> v;
	number.update(l-1, r-1, v);
	/* std::cout << "DONE" << std::endl; */
	cout << number.query(0, n-1) << endl;
	/* std::cout << "DONE" << std::endl; */
  }
}




Measured memory_bytes: 10356
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int n, a, b;

int main()
{
	scanf("%d %d %d", &n, &a, &b);
	if ((a + b) % 2 == 0) printf("Alice\n");
	else printf("Borys\n");
	return 0;
}

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

void _main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N), b(N);
    set<pair<int, int>> st, pts;
    REP (i, N) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        pts.emplace(a[i], b[i]);
        REP (j, 3) REP (k, 3) {
            int ny = a[i] - j;
            int nx = b[i] - k;
            if (ny >= 0 && ny < H - 2 && nx >= 0 && nx < W - 2) {
                st.emplace(ny, nx);
            }
        }
    }
    vector<int> cnt(10, 0);
    int nonzero = 0;
    for (auto p : st) {
        int y, x;
        tie(y, x) = p;
        int sum = 0;
        REP (j, 3) REP (k, 3) {
            pair<int, int> q(y + j, x + k);
            if (pts.count(q)) sum++;
        }
        cnt[sum]++;
        nonzero++;
    }
    cnt[0] = (H - 2) * (W - 2) - nonzero;
    REP (i, 10) cout << cnt[i] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

//比較関数ver
struct st{string str;int point, number;};
bool comp(const st& a, const st& b) {
  if(a.str < b.str)return true;
  else if(a.str > b.str)return false;
  return a.point > b.point;
}

signed main(){
  int n;cin >> n;
  vector<st> vec;
  rep(i,n){
    string str;int s, p = i+1;
    cin >> str >> s;
    vec.push_back(st{str, s, p});
  }
  sort(vec.begin(), vec.end(), comp);
  rep(i,n){
    cout << vec[i].number << endl;
  }
  return 0;
}






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





//modint構造体

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};


int main() {
  int n,m;
  cin >> n >> m;
  vector<int64_t> x(n);
  vector<int64_t> y(m);
  mint h=0;
  mint w=0;
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  rep(i,n-1){
    h += (x[i+1]-x[i])*(i+1)*(n-i-1);
  }
  rep(i,m-1){
    w += (y[i+1]-y[i])*(i+1)*(m-i-1);
  }
  cout << (h.x*w.x)%mod << endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int main()
{
    int n, m, ret = 0;
    cin >> n >> m;
    int max_l = 1, min_r = n + 1;
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        cin >> l >> r;
        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }
    cout << ((max_l <= min_r) ? min_r - max_l + 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b; cin >> a >> b;

  //int ans;
  string ans;
  if (a > b) ans = "a > b";
  else if (a < b) ans = "a < b";
  else ans = "a == b";
  
  cout << ans << endl;
}


Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

const int N = 55556;
bool prime[N];

vector<int> sieve() {
    vector<int> v;
    memset(prime, true, sizeof(prime));
    for(int i = 2; i <= N; i++) {
        if (prime[i]) {
            v.push_back(i);
            for (int j = i; j <= N; j += i)
                prime[j] = false;
        }
    }
    return v;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> s = sieve();
    
    int x = 0;
    for (int i = 0; i < n; i++) {
        while (s[x] % 5 != 1) x++;
        printf("%d ", s[x]);
        x++;
    }
    
    return 0;
}


Measured memory_bytes: 384
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

avg = [T-H[i]*0.006 for i in range(N)]

diff = 10**9
for i in range(N):
    temp = abs(avg[i]-A)
    if temp<diff:
        diff = temp
        idx = i+1
        
print(idx)

Measured memory_bytes: 3064
/*input

*/
#include <iostream>
#include <fstream>
#include <bitset>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <utility>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <assert.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define MOD2 1000000009ULL
#define INF 1000000000ULL
#define F first
#define S second
#define eps 1e-9
#define PI 3.14159265358979
#define gcd __gcd
#define sd(x) scanf("%d", &(x))
#define slld(x) scanf("%lld", &(x))
#define ss(x) scanf("%s", x)
#define sc(x) scanf(" %c", &x)
#define pd(x) printf("%d\n", (x))
#define plld(x) printf("%lld\n", (x));
#define gc getchar

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<int, int> vii;
typedef vector<ll, ll> vll;

void scanint(int &x)
{
    register int c = gc();
    bool flag = false;
    x = 0;
    for(;((c<48 && c!=45) || c>57);c = gc());
    if(c==45)
    {
		flag = true;
		c = gc();
    }
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(flag)
    	x = x - (x<<1);
    return;
}

void scanll(ll &x)
{
	register long long c;
	bool flag = false;
	x = 0;
	for(;((c<48 && c!=45) || c>57);c = gc());
	if(c==45)
	{
		flag = true;
		c = gc();
	}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(flag)
    	x = x - (x<<1);
	return;
}

const int N = 10004;
ll A[N], B[N];

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

	// clock_t clk;
	// clk = clock();
	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);
	
	int n;
	cin >> n;
	for(int i = 1; i<=n; i++)
		cin >> A[i];
	for(int i = 1; i<=n; i++)
		cin >> B[i];
	ll sum2 = 0, sum1 = 0;
	for(int i = 1; i<=n; i++)
	{
		if(B[i] > A[i])
		{
			sum2 += (B[i]-A[i]+1LL)/2LL;
			sum1 += (B[i]-A[i])%2LL;
		}
		else
		{
			sum1 += A[i] - B[i];
		}
	}
	ll x = sum2 - sum1;

	if(x < 0LL)
	{
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";

	// clk = clock() - clk;
	// cout << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	// printf("Time: %lf", ((double)clk)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 384
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
void build(){

}
LL n , nxt;
void init(){
  n = getint() + 1;
}
deque<int> l , r;
void go( LL now ){
  if( now == 1 ) return;
  go( now >> 1 );
  ++ nxt;
  l.push_back( nxt );
  r.push_back( nxt );
  if( now & 1 ){
    ++ nxt;
    l.push_front( nxt );
    r.push_back( nxt );
  }
}
void solve(){
  go( n );
  for( auto i : r )
    l.push_back( i );
  printf( "%d\n" , (int)l.size() );
  for( size_t i = 0 ; i < l.size() ; i ++ )
    printf( "%d%c" , l[ i ] , " \n"[ i + 1 == l.size() ] );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
from collections import defaultdict

N,C = map(int, input().split())
D = [tuple(map(int, input().split())) for _ in range(C)]
grid = [tuple(map(int, input().split())) for _ in range(N)]


# mod_x : (i+j)%3がxで、keyは色、valueは個数
mod_0 = defaultdict(int)
mod_1 = defaultdict(int)
mod_2 = defaultdict(int)


for i in range(N):
    for j in range(N):
        if (i+1 + j+1) % 3 == 0:
            mod_0[grid[i][j]] += 1
        elif (i+1 + j+1) % 3 == 1:
            mod_1[grid[i][j]] += 1
        elif (i+1 + j+1) % 3 == 2:
            mod_2[grid[i][j]] += 1

ans = float("inf")
# mod_0のマスにあるものをiに、mod_1のものをjに、mod_2のものをkに塗り替える
for i in range(C):
    for j in range(C):
        if i == j: continue
        for k in range(C):
            if k in [i,j]:
                continue

            total = 0
            for prev,cnt in mod_0.items():
                total += D[prev-1][i] * cnt
            for prev,cnt in mod_1.items():
                total += D[prev-1][j] * cnt
            for prev,cnt in mod_2.items():
                total += D[prev-1][k] * cnt

            ans = min(ans, total)

print(ans)


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

using namespace std;

const int Nmax = 2e5 + 10;
const int Mod = 1e9 + 7;
const int oo = 1e9;

int n, k;
int a[201];

int main()
{
/**
    #ifndef ONLINE_JUDGE

        ifstream cin("test.in");

    #endif // ONLINE_JUDGE
*/

    cin >> n >> k;

    int d;
    for(int i = 1; i <= k; i++)
    {
        cin >> d;
        int x;
        for(int j = 1; j <= d; j++)
        {
            cin >> x;
            a[x] ++;
        }
    }

    int cnt = 0;

    for(int i = 1; i <= n; i++)
        if(a[i] == 0) cnt++;

    cout << cnt;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int SIZE=110;
int C[SIZE][SIZE];

void init()
{
    REP(i,SIZE){
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i;j++){
            C[i][j]=C[i-1][j-1]+C[i-1][j];
        }
    }
}

signed main()
{
    int N,P; cin>>N>>P;
    int even=0,odd=0;
    REP(i,N){
        int a; cin>>a;
        if(a%2==0) even++;
        else odd++;
    }
    init();
    int ans=0;
    for(int i=0;i<=odd;i++){
        if(i%2==P) ans+=C[odd][i]*(1LL<<even);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import sys

input=sys.stdin.readline

N,K=map(int,input().split())
S=input()

RL=0
LR=0
unhappy=0

for i in range(0,N):
    if S[i]=='R' and S[i+1]=='L':
        RL+=1
    elif S[i]=='L' and S[i+1]=='R':
        LR+=1

if S[0]=='L' and S[N-1]=='L':
    if K>=RL:
        print(N-1)
    else:
        RL-=K
        print(N-2*RL-1)
elif S[0]=='R' and S[N-1]=='R':
    if K>=RL:
        print(N-1)
    else:
        RL-=K
        print(N-2*RL-1)
elif S[0]=='L' and S[N-1]=='R':
    if K>RL:
        print(N-1)
    elif K==RL:
        print(N-2)
    else:
        RL-=K
        print(N-2*RL-2)
else:
    if K>RL:
        print(N-1)
    elif K==RL:
        print(N-1)
    elif K==RL-1:
        print(N-2)
    else:
        RL-=K
        print(N-2*RL)


Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<ll> d;
  rep(i, x) d.push_back(p[i]);
  rep(i, y) d.push_back(q[i]);
  rep(i, c) d.push_back(r[i]);
  ll ans = 0;
  sort(d.rbegin(), d.rend());
  rep(i, x + y) ans += d[i];
  cout << ans << endl;

}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
ll a,b,c,k,m;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c>>k;
	m=max({a,b,c});
	a+=b;
	a+=c;
	a-=m;
	FOR(i,0,k){
		m*=2;
	}
	m+=a;
	pri(m);
	return 0;
}

Measured memory_bytes: 256
/* Doctor's Memorable Code */

#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<cctype>

using namespace std;

string sbits(unsigned int x, int n){
	string ret;
	for(int i = 0; i < n; i++){
		ret += (x & 1) + '0';
		x >>= 1;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

string DoctorTableAD(char c){
	string ret;
	if( isupper(c) ){
		ret = sbits(c - 'A', 5);
	}else{
		const char symb[] = " .,-'\?";
		for(int i = 0; i < sizeof(symb)/sizeof(*symb); i++){
			if( c == symb[i] ){
				ret = sbits(i+26, 5);
				break;
			}
		}
	}
	return ret;
}

string DoctorTableDA(string &s){
	unsigned int pos = 0;
	string ret, sub;
	const char ctable[] = " ',-.\?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char table[][16] =
{"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
	
	while( true ){
		sub += s[pos++];
		for(int i = 0; i < sizeof(table)/sizeof(*table); i++){
			if( 0 == sub.compare(table[i]) ){
				ret += ctable[i];
				sub.clear();
				break;
			}
		}
		if( pos >= s.length() ) break;
	}
	return ret;
}

string DoctorLovedDecode(string &raw){
	string s;
	for(unsigned int i = 0; i < raw.length(); i++){
		s += DoctorTableAD(raw[i]);
	}
	return DoctorTableDA( s );
}

int main(void){
	while(true){
		string s;

		getline(cin,s);
		if( cin.eof() ) break;
		
		cout << DoctorLovedDecode( s ) << "\n";
	}
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  x, ans, a, b;
  cin >> x;
  
  
  a = x/500;
  b = (x - a * 500)/5;
  ans = 1000 * a  + 5 * b; 
  
  
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const ll INF = ll(1e18)+1;
 
int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i,n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) r = c; else l = c;
          }
          tot += n-r;
        } else {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 4800
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
const int N = 100005;

struct edge{ int v, w; };

struct node{
	int u, d;
	bool operator < (const node & r) const {
		return d > r.d;
	}
};

int dis[N], vis[N];
vector<edge> e[N];
priority_queue<node> q;

void Dijkstra(){
	memset(dis, 0x3f, sizeof(dis));
	dis[1] = 0; q.push((node{1, 0}));
	while(q.size()){
		int u = q.top().u, d = q.top().d; q.pop();
		if(d != dis[u]) continue;
		for(int i = 0; i < e[u].size(); i++){
			int v = e[u][i].v, w = e[u][i].w;
			if(dis[v] > dis[u] + w){
				dis[v] = dis[u] + w;
				q.push((node){v, dis[v]});
			}
		}
	}
	return;
}

int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		e[i-1].push_back((edge) {i, 1});
		e[i].push_back((edge) {(i*10) % n, 0});
	}
	Dijkstra();
	cout << dis[0] + 1 << endl;
	return 0;
}

Measured memory_bytes: 6780
#include <iostream>
using namespace std;
int gcd(int a, int b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main()
{
	int n; cin >> n ;
	int a[3]; for(int i=0;i<n;i++) cin >> a[i] ;
	int m=gcd(a[0], a[1]);
	if(n==3) m=gcd(m, a[2]);
	bool* flag=new bool[m+1];
	flag[1]=true;
	for(int i=2;i<=m;i++)
	{
		if(m%i!=0) continue;
		for(int j=i;j<=m;j+=i) flag[i]=true;
	}
	for(int i=1;i<=m;i++)
		if(flag[i]==true) cout << i << endl;
}

Measured memory_bytes: 1212
// УЛЬЯНА САМАЯ ЛУЧШАЯ В МИРЕ!!!!!!!!!!!!!

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define endl '\n'

struct __init {
    __init() {
        cin.tie(nullptr);
        std::iostream::sync_with_stdio(false);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        std::mt19937 rand(300);
    }

    ~__init() {
        #ifdef SEREZHKA
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC << endl;
        #endif
    }
} init;

const ll inf = (ll) 1e9 + 7ll;
const int maxn = (int) 1e6 + 17;

int n, k;

bool read() {
    if (!(cin >> n >> k))
        return false;

    return true;
}

void solve() {
    ll ans = 0;

    for (int a = 1; a <= n; ++a) {
        int t = n - n % a;
        ans += max(0, min(a, k) * (t / a) - 1);
        ans += min(n - t + 1, k);
    }

    cout << 1ll * n * n - ans << endl;
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;

    bool res = true;
    for (int i = 0; i < a + b + 1; i++) {
        if ((i == a && s[i] != '-') || (i != a && s[i] == '-')) {
            res = false;
        }
    }

    cout << (res == 1 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/*
貪欲
後ろから見る
DP
順位表をチェック



*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,ll>,ll> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);

vector<int> V[110000];

int C[110000];
bool visit[110000];

int main(){
    int N,a[110000],b[110000];
    cin>>N;
    for(int i=0;i<N-1;i++){
        cin>>a[i]>>b[i];
        a[i]--; b[i]--;
        V[a[i]].push_back(b[i]); V[b[i]].push_back(a[i]);
    }
    for(int i=0;i<110000;i++) visit[i]=false;
    queue<int> que;
    que.push(0);
    C[0]=-1;
    map<P,int> M;
    int ans=0;
    while(!que.empty()){
        int now=que.front(); que.pop();
        visit[now]=true;
        int count=1;
        for(int i=0;i<V[now].size();i++){
            int next=V[now][i];
            if(visit[next]) continue;
            if(count==C[now]) count++;
            M[P( min(now,next),max(now,next) )]=count;
            ans=max(ans,count);
            que.push(next);
            C[next]=count;
            count++;
        }
    }
    cout<<ans<<endl;
    for(int i=0;i<N-1;i++){
        cout<<M[P( min(a[i],b[i]),max(a[i],b[i])  )]<<endl;
    }

}


Measured memory_bytes: 13824