akhauriyash/Code-Regression huggingface dataset:
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;
static class Program{
	const int mod=(int)1e9+7;
		static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var h=sc.Ia3(0);
		int[] ans=new int[n+1];
		int[] mm=new int[n+1];
		for(int i = n;i>=0;i--) {
			int q=(int)Sqrt(i);
			if(h[i]%2==mm[i]%2){continue;}
			ans[i]++;
			for(int j = 1;j<=q;j++) {
				if(i%j==0){
					mm[j]++;
					if(j!=i/j){mm[i/j]++;}
				}
			}
		}
		StringBuilder sb=new StringBuilder();
		int m=0;
		for(int i = 1;i<=n;i++) {
			if(ans[i]>1){
				m=-1;
				break;
			}
			if(ans[i]==1){
				sb.Append((m!=0?" ":"")+i);
				m++;
			}
		}
		sb.Append("\n");
		Console.WriteLine("{0}",m);
		if(m>0){Console.Write(sb);}
	}
}

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(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.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: 34132
n, c = map(int, input().split())
xvs = [tuple(map(int, input().split())) for _ in range(n)]
mx1 = [0]
acc = 0
prv = 0
for x, v in xvs:
    acc += v - (x-prv)
    prv = x
    mx1.append(max(acc, mx1[-1]))
mx2 = [0]
acc = 0
prv = c
for x, v in xvs[::-1]:
    acc += v - (prv-x)*2
    prv = x
    mx2.append(max(acc, mx2[-1]))
ans1 = 0
for i in range(n+1):
    ans1 = max(ans1, mx1[n-i]+mx2[i])
mx1 = [0]
acc = 0
prv = 0
for x, v in xvs:
    acc += v - (x-prv)*2
    prv = x
    mx1.append(max(acc, mx1[-1]))
mx2 = [0]
acc = 0
prv = c
for x, v in xvs[::-1]:
    acc += v - (prv-x)
    prv = x
    mx2.append(max(acc, mx2[-1]))
ans2 = 0
for i in range(n+1):
    ans2 = max(ans2, mx1[n-i]+mx2[i])
print(max(ans1, ans2))

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

signed main(void){
  int N; cin >> N;
  bool flag = true;
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    
    if( a % 2 == 0 ){ 
      if( a % 3 != 0 && a % 5 != 0 ){ flag = false;}
    }
    
  }
  if(flag){ cout <<"APPROVED" << endl;}
  else{ cout << "DENIED" << endl;}
  
  return 0;
}
 
 

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

int main() 
{
  long long k,n;
  cin >> k >> n;
  vector<long long> data(n);
  for(long long i = 0; i < n; i++)
  {
    cin >> data.at(i);
  }

  long long a = data.at(n - 1) - data.at(0);
  vector<long long> table(1000000, 0);
  table.at(a) = 1;
  for(long long i = 0; i < n - 1; i++)
  {
    long long sum = k - data.at(i+1) + data.at(i);
    table.at(sum) = 1;
  }
  for(long long i = 0; i < 1000000; i++)
  {
    if(table.at(i) == 1)
    {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
#define allSum(a) accumulate(a.begin(),a.end(),0)
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

bool check(int n,vector<char> d){
  str s=to_string(n);
  rep(i,s.length()){
    rep(j,d.size()){
      if(s[i]==d[j])return false;
    }
  }
  return true;
}

signed main(){
  int n,k;
  cin>>n>>k;
  vector<char> a(k);
  rep(i,k)cin>>a[i];
  int ans;
  for(ans=n;ans<=100000;++ans){
    if(check(ans,a))break;
  }
  cout<<ans<<endl;
  return 0;
}



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

fn main() {
    let stdin = stdin();
    let mut lock = stdin.lock();
    let mut str1 = String::new();
    lock.read_line(&mut str1).unwrap();
    let vec: Vec<_> = str1.trim().split_whitespace().map(|x|
    u64::from_str(x).unwrap()).collect();
    let mut value = 0u32;
    let mut sanjo = vec[0];
    while sanjo <= vec[1] {
        sanjo *= 2u64;
        value += 1;
    }
    println!("{}", value);
}

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

int calc_dist (int x, int y, int x_1, int y_1){
	int dist = abs(x_1 - x) + abs(y_1 - y);
    return dist;
}
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
	cin >> vec.at(i);
  }
  int check_num = 1;
  int del_num = 0;
  int del_before = -1;
  for(int k = 0; k < N; k++){
  	  if(vec.at(k) == check_num){
        check_num++;
        if(del_before == -1){
          	del_num += k;
        }
        else{
        	del_num += k - del_before - 1;
        }
        del_before = k;
      }
  }
  if(del_before == -1) cout << -1 << endl;
  else if(del_before != N - 1){
    del_num += N - 1 - del_before;
    cout << del_num << endl;
  }
  else cout << del_num << endl;
  return 0;
}

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

ll gcd(ll a, ll b) { if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
int main() {
	ll a;
	while (scanf("%lld", &a), a) {
		vector<ll>v;
		for (ll i = 1; i*i <= a; i++) {
			if (a%i == 0) {
				v.push_back(i);
				if (i != a / i)v.push_back(a / i);
			}
		}
		if (v.size() > 6000)abort();
		sort(v.begin(), v.end());
		int cnt = 0;
		rep(i, v.size())for (int j = i; j < v.size(); j++) {
			if (lcm(v[i], v[j]) == a)cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a, b, flg;

		a = sc.nextInt();
		b = sc.nextInt();

		flg = a - b;

		if (0 <= flg) {
			for (int i = 0; i < a; i++) {
				System.out.print(b);
			}
		} else if (flg < 0) {
			for (int i = 0; i < b; i++) {
				System.out.print(a);
			}
		}

		sc.close();

	}

}


Measured memory_bytes: 22868
N, M = list(map(int, input().split()))
XList = list(map(int, input().split()))

def main():
    if N >= M:
        print(0)
        return
    XList.sort()
    dX = [XList[i+1]-XList[i] for i in range(len(XList)-1)]
    dX.sort(reverse=True)
    ans = XList[-1]-XList[0]-sum(dX[:N-1])
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  int D,G;
  cin>>D>>G;
  vector<ll> p(D),c(D);
  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }
  ll ans=1000000;
  for(int i=0;i<(1<<D);i++){
    ll goal=G;
    ll problems=0;
    int chosen=-1;
    for(int j=0;j<D;j++){
      if((i>>j)&1==1){
        goal-=((j+1)*100*p[j]+c[j]);
        problems+=p[j];
      }else{
        chosen=j;
      }
    }
    if(goal<=0){
      ans=min(ans,problems);
    }else{
      int add=(goal-1)/(100*(chosen+1))+1;
      if(add<=p[chosen]){
        ans=min(ans,problems+add);
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int main()
{
  int t;
  cin>>t;
  long long a = t*t*t;
  cout<<a<<endl;
}

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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1,2,4,3);}
  void roll_y(){roll(0,2,5,3);}
  void roll_x(){roll(0,1,5,4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
};

bool eq(Cube c1, Cube c2){
  for(int i=0;i<6;i++){
    if(c1.f[i] != c2.f[i]) return false;
  }
  return true;
}

bool equal(Cube c1, Cube c2){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if(eq(c1, c2)) return true;
      c1.roll_z();
    }
    if(i % 2 == 0) c1.roll_y();
    else c1.roll_x();
  }
  return false;
}

Cube C[100]; int n;

bool check(){
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(equal(C[i], C[j])) return false;
    }
  }
  return true;
}

int main(){
  cin >> n;
  for(int j=0;j<n;j++){
    for(int i=0;i<6;i++){
      cin >> C[j].f[i];
    }
  }

  if(check()) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    string n;
    cin >> n;
    if(n.at(0)=='9' || n.at(1)=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import static java.lang.System.in;
import static java.lang.System.out;

import java.util.*;


public class Main {
	Scanner sc = new Scanner(in);
	
	int calc(String s) {
		char[] m = s.toCharArray();
		int n = m.length;
		int i = 0;
		int ans = 0;
		int pre = 1;
		while (i < n) {
			switch(m[i]) {
			case 'm':
				ans += pre*1000;
				i++;
				pre = 1;
				break;
			case 'c':
				ans += pre*100;
				i++;
				pre = 1;
				break;
			case 'x':
				ans += pre*10;
				i++;
				pre = 1;
				break;
			case 'i':
				ans += pre;
				i++;
				pre = 1;
				break;
			default:
				pre = Integer.parseInt(String.valueOf(m[i]));
				i++;
				break;
			}
		}
		return ans;
	}
	
	String calc(int n) {
		int m, c, x, i;
		m = n/1000;
		c = (n-1000*m)/100;
		x = (n-1000*m-100*c)/10;
		i = n-1000*m-100*c-10*x;
		
		String ans = "";
		if (m > 1)
			ans += String.format("%dm", m);
		else if (m == 1)
			ans += "m";
		
		if (c > 1)
			ans += String.format("%dc", c);
		else if (c == 1)
			ans += "c";
		
		if (x > 1)
			ans += String.format("%dx", x);
		else if (x == 1)
			ans += "x";
		
		if (i > 1)
			ans += String.format("%di", i);
		else if (i == 1)
			ans += "i";
		
		return ans;
	}
	
	void run() {
		int n = Integer.parseInt(sc.next());
		String a, b;
		
		for (int i = 0; i < n; i++) {
			a = sc.next();
			b = sc.next();
			out.println(calc(calc(a)+calc(b)));
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}
}

Measured memory_bytes: 37116
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String U = sc.next();
    if(U.equals(S)){
      System.out.println(A-1);
      System.out.println(" ");
      System.out.println(B);
    }else{
      System.out.println(A);
      System.out.println(" ");
      System.out.println(B-1);
    }
  }
  

  
}

Measured memory_bytes: 25172
/* ABC136-A.c
   Takatan */

#include<stdio.h>
int main(void){
    int water1, water2, max;

    scanf( "%d %d %d" , &max, &water1, &water2);

    water2 = water1 + water2 - max; /* 入力 */
    if(water2<0){ /* 負の値の時0とする */
        water2 = 0;
    }

    printf( "%d\n" , water2); /* 出力 */
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<queue>
#include<vector>
#include<utility>

const int INF=999999999;

typedef std::pair<int,int> path_t;//first->node second->cost

struct nodes{
		int cost,num;
		std::vector<path_t> path;
		bool visited=false;
};
bool operator>(const nodes node_a,const nodes node_b){
		return node_a.cost>node_b.cost;
}
std::priority_queue<nodes,std::vector<nodes>,std::greater<nodes> > pq;

int v,e,r;
nodes node[100000];

void initialize(void){
	for(int lp=0;lp<100000;lp++){
		node[lp].cost=INF;
		node[lp].num=lp;
	}
}

void input(void){
	int s,t,d;
	scanf("%d%d%d",&v,&e,&r);
	for(int lp=0;lp<e;lp++){
		scanf("%d%d%d",&s,&t,&d);
		node[s].path.push_back(std::make_pair(t,d));
	}
}
void solve(void){
	node[r].cost=0;
	node[r].visited=true;
	pq.push(node[r]);
	while(!pq.empty()){
		nodes node_now=pq.top();
		pq.pop();
		for(int lp=0;lp<(int)node_now.path.size();lp++){
			int nextcost=node_now.path[lp].second+node_now.cost;
			int nextnode=node_now.path[lp].first;
			//printf("nownode:%d nowcost:%d nextnode:%d nextcost:%d\n",node_now.num,node_now.cost,nextnode,nextcost);
			if(node[nextnode].visited==false && nextcost<node[nextnode].cost){
				node[nextnode].cost=nextcost;
				pq.push(node[nextnode]);
			}
		}
	}
}

void output(void){
	for(int lp=0;lp<v;lp++){
		if(node[lp].cost==INF){
			printf("INF\n");
		}else{
			printf("%d\n",node[lp].cost);
		}
	}
}

int main(void){
	initialize();
	input();
	solve();
	output();
	return 0;
}




Measured memory_bytes: 25456
#include<bits/stdc++.h>
#define ll long long
#define pr pair<ll,ll>
using namespace std;
int main() {
    ll s, bd = 1e9;
    cin >> s;
    if (s == 1e18)cout << 0 << ' ' << 0 << ' ' << 1000000000 << ' ' << 0 << ' ' << 0 << ' ' << 1000000000;
    else if (s <= bd)cout << 0 << ' ' << 0 << ' ' << 0 << ' ' << 1 << ' ' << s << ' ' << 0;
    else {
        ll L = s / bd + 1, R = L * bd - s;
        cout << 0 << ' ' << 0 << ' ' << bd << ' ' << 1 << ' ' << R << ' ' << L;
    }
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;




int main(){
   ll n, t;
   cin >> n >> t;
   vector<ll> a(n);
   rep(i, n)cin >> a[i];
   reverse(ALL(a));
   vector<ll> sum(n);
   rep(i, n){
      if(i == 0)sum[i] = a[i];
      else sum[i] = max(a[i], sum[i - 1]);
   }
   reverse(ALL(a));
   map<ll, int> mp;
   rep(i, n){
      mp[sum[n - i - 1] - a[i]]++;
   }
   ll res = 0;
   for(auto m : mp){
      res = m.second;
   }
   cout << res << endl;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n],b[n];
	int c=0;
	int flag=0;
	for(int i=0;i<n;i++){
	    cin>>a[i]>>b[i];
	    if(a[i]==b[i]){
	        c++;
	    }else{
	        c=0;
	    }
	    
	    if(c==3){
	        cout<<"Yes"<<endl;
	        flag=1;
	        break;
	    }
	}
	if(flag==0){
	    cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int A, B;
  for(int j = 0; j < a.size(); j += 2) {
    A += a.at(j);
  }
  
  for(int k = 1; k < a.size(); k += 2) {
    B += a.at(k);
  }
  
  cout << A - B << endl;
}

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

int main()
{
    char s;
    cin >> s;
    if(s=='A')
        cout << "T";
    else if(s=='T')
        cout << "A";
    else if(s=='C')
        cout << "G";
    else
        cout << "C";
    return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
P = 10**9+7

def C(n, k):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % P
        b = b * (i+1) % P
    return a * pow(b, P-2, P) % P

print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)

Measured memory_bytes: 3064
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val n = input.nextLine().toInt
      println(1.to(9).map(_ * 111).filter(_ >= n).min)
    }

  }

}


Measured memory_bytes: 27032
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

class unionFindTree {
private:
	vector <int> tree;
	vector <int> rank;

public:
	unionFindTree() {}

	unionFindTree(int sz) {
		tree = vector <int> (sz);
		rank = vector <int> (sz, 0);
		for(int i = 0; i < tree.size(); i++)
			tree[i] = i;
	}

	unionFindTree(const unionFindTree &o) {
		tree = o.tree;
		rank = o.rank;
	}

	unionFindTree &operator=(const unionFindTree &o) {
		tree = o.tree;
		rank = o.rank;
		return (*this);
	};

	int root(int x) {
		return tree[x] == x ? x : tree[x] = root(tree[x]);
	}

	bool same(int a, int b) {
		return root(a) == root(b);
	}

	void unite(int a, int b) {
		a = root(a);
		b = root(b);
		if(a == b)return;

		if(rank[a] < rank[b]) swap(a, b);

		tree[b] = a;
		rank[a] += rank[a] == rank[b];
	}

	int size() {
		return tree.size();
	}
};

class Kruskal {
	private:
		struct edge {
			int u, v, cost;
			bool operator< (const edge& e) const {
				return cost < e.cost;
			}
		};
		vector <edge> es;
		unionFindTree uft;
		int V;

	public:
		Kruskal(int v, int e) {
			V = v;
			es = vector <edge> (e);
			uft = unionFindTree(V);
		}

		void addEdge(int start, int end, int cost) {
			es.push_back({start, end, cost});
		}

		int execute() {
			sort(es.begin(), es.end());
			int res = 0;
			for(int i = 0; i < es.size(); i++) {
				edge e = es[i];
				if(!uft.same(e.u, e.v)) {
					uft.unite(e.u, e.v);
					res += e.cost;
				}
			}
			return res;
		}
};

signed main() {
	int v, e;
	cin >> v >> e;
	Kruskal kr(v, e);

	rep (i, e) {
		int s, t, w;
		cin >> s >> t >> w;
		kr.addEdge(s, t, w);
		kr.addEdge(t, s, w);
	}

	cout << kr.execute() << endl;

}


























Measured memory_bytes: 12500
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int n, m;
vector< P > v[10000];
int r[10000];

int main()
{
	scanf("%d %d", &n, &m);
	while (true){
		int s, t, e;
		scanf("%d %d %d", &s, &t, &e);
		if (!s) break;
		v[--t].push_back(P(--s, e));
	}
	
	int L;
	scanf("%d", &L);
	for (int ca = 0; ca < L; ca++){
		memset(r, 0, sizeof(r));
		for (int i = 0; i < m; i++){
			int b;
			scanf("%d", &b);
			for (int j = 0; j < v[i].size(); j++){
				r[ v[i][j].first ] += v[i][j].second * b;
			}
		}
		for (int i = 0; i < n; i++){
			if (i) printf(" ");
			printf("%d", r[i]);
		}
		puts("");
	}
}

Measured memory_bytes: 2220
#include<stdio.h>
int main(){
    int n, k;
    scanf("%d%d",&n,&k);
    int a[n + 1];
    for(int i = 0; i < n; i++)
        scanf("%d",&a[i + 1]);
    for(int i = k + 1; i <= n; i++){
        if(a[i - k] < a[i])
            puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 2424
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 310000
ll MOD=998244353;
ll inv[N];

vector<vec> G(N);
main(){
    ll n=lin();
    ll ans=0;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll a=i,b=n/i;
            if(a-1>b)ans+=a-1;
            if(b-1>a)ans+=b-1;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 7552
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N;
	cin>>N;
	vector<ll>x(N);
	rep(i,0,N)cin>>x[i];
	partial_sum(all(x),x.begin());
	ll mina=LLONG_MAX;
	rep(i,0,N-1){
		mina=min(mina,abs(x.back()-2*x[i]));
	}
	cout<<mina;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int H,W;
cin >> H >> W;
vector<string> S(H),T(H);

rep(h,H) {
    cin >> S[h];
    T[h] = S[h];
}

rep(h,H) rep(w,W) {
    if(S[h][w] == '#') {
        T[h][w] = '#';
        continue;
    }
    int cnt = 0;
    for(int i = -1;i <= 1;i++) {
        for(int j = -1;j <= 1;j++) {
            if(0 <= h+i && h+i <= H-1 && 0 <= w+j && w+j <= W-1) {
                if(S[h+i][w+j] == '#') cnt++;
            }
        }
    }
    T[h][w] = '0'+ cnt;
}

rep(h,H) cout << T[h] << endl;

return 0;
}

Measured memory_bytes: 256
local x,y,a,b,c=io.read("n","n","n","n","n")
local A,B={},{}
local t={}

for i=1,a do
    A[i]=io.read("n")
end
table.sort(A,function(a,b)
    return a>b
end)
for i=1,x do
    table.insert(t,A[i])
end

for i=1,b do
    B[i]=io.read("n")
end
table.sort(B,function(a,b)
    return a>b
end)
for i=1,y do
    table.insert(t,B[i])
end

for i=1,c do
    table.insert(t,io.read("n"))
end
table.sort(t,function(a,b)
    return a>b
end)

local max=0
for i=1,x+y do
    max=max+t[i]
end
print(string.format("%d",max))

Measured memory_bytes: 8716
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

// 最大公約数
ll gcd(ll a, ll b){
    ll c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

// 最小公倍数
ll lcm( ll m, ll n ){
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main(void){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll e = lcm(c, d);
    ll ans;
    ans = b / c - a / c + (a % c == 0 ? 1 : 0);
    ans += b / d - a / d + (a % d == 0 ? 1 : 0);
    ans -= b / e - a / e + (a % e == 0 ? 1 : 0);
    cout << (b - a + 1) - 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;

int next_alp_pos[100000][26];

void solve();

int main(void){
    string s, t;
    cin >> s;
    cin >> t;
    ll ans;
    int lenS = s.length();
    int lenT = t.length();
    int index[26] = {};
    vector<int> alphabet[26];
    rep(i, lenS) alphabet[s[i]-'a'].push_back(i);
    rep(i, lenS){
        index[s[i]-'a']++; //自分の文字のindexを進める
        rep(j, 26){
            if(index[j] < alphabet[j].size()) next_alp_pos[i][j] = alphabet[j][index[j]];
            else next_alp_pos[i][j] = -1;
        }
    }
    bool ok = true;
    rep(i, lenT) if(alphabet[t[i] - 'a'].size() == 0) ok = false;
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    ll lap = 0;
    int idx_T = 0;
    int pos_S = 0; //S上のどこにいるか
    bool first_s0 = true;
    //next_alp_posはs[0]を亡き者として扱うので、別途考えなきゃいけない
    while(idx_T < lenT){
        // t[idx_T]を探す
        if(pos_S == 0 && first_s0 && s[0] == t[idx_T]){
            if(idx_T == lenT-1){
                cout << lap*lenS + 1 << endl;
            }
            idx_T++;
            first_s0 = false;
        }
        int val = next_alp_pos[pos_S][t[idx_T] - 'a'];
        if(val == -1){
            lap++;
            pos_S = 0;
            first_s0 = true;
        }
        else{
            if(idx_T == lenT-1){
                cout << lap*lenS + val + 1 << endl;
            }
            pos_S = val;
            idx_T++;
        }
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 11264
// Problem : A - Falling Asleep
// Contest : Dwango Programming Contest 6th
// URL : https://atcoder.jp/contests/dwacon6th-prelims/tasks/dwacon6th_prelims_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2525.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
		
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const int INF = 1e18;
const int N = (int)3e5+5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	vector<pair<string, int>> v;
	for(int i = 0; i < n; i++)
	{
		string s;
		int x;
		cin >> s >> x;
		v.push_back({s, x});
	}
	bool flag = false;
	string tar; cin >> tar;
	int cnt = 0;
	for(auto it : v)
	{
		string x = it.first;
		int  y = it.second;
		if(flag)
			cnt += y;
		if(x == tar)
			flag = true;
	}
	cout << cnt;
 	return 0;
}


Measured memory_bytes: 384
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	        }

	        int H = 1000005;
	        int[] m = new int[H];
	        int[] p = new int[H];
	        int k=0;
	        m[1]=1;
	        for(int i=2;i<H;i++) {
	        	if(m[i]==0) {
	        		m[i]=1;
	        		p[k]=i;
	        		k++;
	        		for(int j=i+i;j<H;j=j+i) {
	        			m[j]=i;
	        		}
	        	}
	        }		        
	        
	        int[] m2 = new int[1000005];
	        String ans = "pairwise coprime";
	        for(int i=0;i<N;i++) {
	        	while(a[i]!=1) {
	        		if(m[(int)a[i]]!=1) {
	        				int tmp =(int)a[i];
		        			m2[m[tmp]]++;
		        			while(a[i]%m[tmp]==0) {
		        				a[i]=a[i]/m[tmp];
		        			}
	        		} else {
	        			m2[(int)a[i]]++;
	        			a[i]=1;
	        		}
	        	}
	        }
	        
	        for(int i=0;i<1000005;i++) {
	        	if(m2[i]>1)ans = "setwise coprime";
	        	if(m2[i]==N) {
	        		ans = "not coprime";
	        		break;
	        	}
	        }
	        
	        System.out.println(ans);
		 }
		 
	}

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

int main()
{
    int n,i,cnt;
    cin>>n>>str;
    n-=3;
    cnt=0;
    for(i=0;i<=n;i++)
    {
        if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = 2005;
vector<int> T[N];
int dist[N];

int n, k;
int solve(vector<int> st, int d){
    for(int i = 1; i <= n; i ++ )
        dist[i] = 123141;
    queue<int> ff;
    for(auto x : st){
        ff.push(x);
        dist[x] = d;
    }
    int node;
    while(!ff.empty()){
        node = ff.front();
        ff.pop();
        for(auto x : T[node]){
            if(dist[node] + 2 < dist[x]){
                dist[x] = dist[node] + 2;
                ff.push(x);
            }
        }
    }
    int res = 0;
    for(int i = 1; i <= n; i ++ ){
        if(dist[i] > k){
            res ++ ;
        }
    }
    return res;
}

int main(){
    fastIO;
    cin >> n >> k;
    int res = 123141;
    int u[n], v[n];
    for(int i = 1 ;i < n ; i ++ ){
        cin >> u[i] >> v[i];
        T[u[i]].push_back(v[i]);
        T[v[i]].push_back(u[i]);
    }
    for(int i = 1; i <= n; i ++ )
        res = min(res,solve({i},0));
    for(int i = 1; i < n ; i ++ )
        res = min(res,solve({u[i],v[i]}, 1));
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,a[105];scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1,j;i<=n;)
	{
		j=i;
		while(a[i]==a[j]&&i<=n)i++;
		ans+=(i-j)/2;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  int H,W;
  cin >> H >> W;
  int D;
  cin >> D;
  vector<P> G(H*W+1);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int num;
      cin >> num;
      G[num] = make_pair(i,j);
    }
  }
  vector<int> S(H*W+1,0);
  for(int i=D+1; i<=H*W; i++){
    S[i] += S[i-D] + abs(G[i].first-G[i-D].first) + abs(G[i].second-G[i-D].second);
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l,r;
    cin >> l >> r;
    cout << S[r] - S[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int A,B; cin>>A>>B;
  cout<<(B==1?0:A-B);

}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

//非再帰累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod==-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m,k,ans=0;
  std::cin>>n>>m>>k;

  std::vector<ll> facto(n*m);

  facto[0]=1;
  rep(i,1,n*m)facto[i]=(facto[i-1]*i)%MOD;

  rep(i,1,n)ans=(ans+(n-i)*m*m*i)%MOD;
  rep(i,1,m)ans=(ans+(m-i)*n*n*i)%MOD;

  ans=(ans*facto[n*m-2])%MOD;
  ans=(ans*pow_mod(facto[n*m-k],MOD-2,MOD))%MOD;
  ans=(ans*pow_mod(facto[k-2],MOD-2,MOD))%MOD;

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 1792
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N;  cin >> N;
    string S; cin >> S;
    
    int white = 0, black = 0;
    REP(i,N) {
        if (S[i] == '.') white++;
        else black++;
    }

    int ans = white;
    int w = 0, b = 0;
    REP(i,N) {
        if (S[i] == '.') w++;
        else b++;

        ans = min(ans, b + white - w);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B) && (B == C) && (A+B>C) && (A+C>B) && (B+C>A))
    {
     cout << "Yes";

    }else {
     cout << "No";
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
constexpr int MAXN = (1 << 20) + 5;
constexpr int MOD = 1e9 + 7;
constexpr double eps = 1e-6;
constexpr int INF = 1e9 + 7;
int dir[4][2] = { { -1,0 },{ 0,1 },{ 1,0 },{ 0,-1 } };

int main()
{
	//freopen("in.in", "r", stdin);&
	//freopen("out.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", min(a, b) + min(c, d));

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

static const int MAX = 100;

static const long long INF = (1LL << 32 );


int n;
long long d[MAX][MAX];

void floyd() {
  for( int k = 0; k < n; k++ ) {
    for(int i = 0; i < n; i++ ) {
      if( d[i][k] == INF ) continue;
      for( int j = 0; j < n; j++ ) {
        if( d[k][j] == INF ) continue;
        d[i][j] = min( d[i][j], d[i][k] + d[k][j] );
      }
    }
  }
}

int main() {
      
   int s, t, c, e;
  
   cin >> n >> e;
   for( int i = 0; i < n; i++ ) {
    for( int j = 0; j < n; j++) {
      d[i][j] = ( (i == j)? 0 : INF );
    }
   }

   while ( e-- ) {
   	  cin >> s >> t >> c;
   	  d[s][t] = c;
   	}
   
    floyd();

    bool negative = false;
    for (int i = 0; i < n; i++ ) if(d[i][i] < 0 ) negative = true;
   
    if( negative ) { cout << "NEGATIVE CYCLE" << endl; }
    else {
      for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < n; j++ ){
          if( j ) cout << " ";
          if (d[i][j] == INF )cout << "INF";
          else cout << d[i][j];
        }
        cout << endl;
      }
    }

   return 0;
}




Measured memory_bytes: 3176
# C - X: Yet Another Die Game
def main():
    x = int(input())

    if x%11==0:
        print((x//11)*2)
    elif x%11<=6:
        print((x//11)*2+1)
    else:
        print((x//11)*2+2)
  
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
#include<cstdio>
int main(){
	int N,K,X,Y;
	int sum;
	scanf("%d%d%d%d",&N,&K,&X,&Y);
	if(N >= K){
		sum = K * X + (N - K) * Y;
		}
	else  sum = N * X;
	printf("%d\n",sum);
	}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,res=1<<30;
    long long sum=0;
    cin>>n;
    while(n--) {
	int x=gi(),y=gi();
	if(x<=y) sum+=x;
	else sum+=x,res=min(res,y);
    }
    if(res==1<<30) puts("0");
    else cout<<sum-res;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	long long h, w;
	cin >> h >> w;

	long long res = h * w;
	for (int i = 0; i < 2; ++i) {
		for (int j = 1; j < h; ++j) {
			long long s_min = j * w;
			long long s_max = j * w;
		
			res = min(res, max(s_max, (h - j) * ((w + 1) / 2)) - min(s_min, (h - j) * (w / 2)));
        	if (h - j > 1) {
        		res = min(res, max(s_max, ((h - j + 1) / 2) * w) - min(s_min, ((h - j) / 2) * w));
        	}
        }
		
		swap(h, w);
	}

	cout << res << endl;

	return 0;
}


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

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

int main(){
    int d,t,s; cin>>d>>t>>s;
    if(t*s<d) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3620
n=int(input())
a=list(map(int, input().split()))
b = 1
anc = 0
roop = 0
if 1 in a:
    for i,v in enumerate(a):
        if v == b:
            anc += roop
            temp = i
            b+=1
            #print('roop',roop)
            roop = 0
            #print('b',b)
            #print('temp',temp)
            #print('anc',anc)

        else:
            roop +=1
            if i == n-1:
                
                anc += roop
    print(anc)
else:

    print(-1)



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[252521];
  cin>>n;
  ll ans=0;
  ll ma=0;
  REP(i, n){
    cin>>a[i];
    if(ma>a[i]){
      ans+=ma-a[i];
    }
    else{
      ma=a[i];
    }
  }
  cout<<ans<<'\n';
  return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W;
string S[110][110];
signed main() {
    cin >> H >> W;
    int y, x;
    rep(i, H) {
        rep(j, W) {
            cin >> S[i][j];
            if (S[i][j] == "snuke") { y = i, x = j; }
        }
    }
    cout << (char)('A' + x) << y + 1 << endl;
}


Measured memory_bytes: 384
N,M = [int(zz) for zz in input().split()]

ans = [-1]*N

if N == 1:
    for _ in range(M):
        s,c = [int(zz) for zz in input().split()]
        if ans[s-1] != -1 and c != ans[s-1]:
            print(-1)
            exit()
        else:
            ans[s-1] = c
else:
    for _ in range(M):
        s,c = [int(zz) for zz in input().split()]
        if s == 1 and c == 0:
            print(-1)
            exit()
        if ans[s-1] != -1 and c != ans[s-1]:
            print(-1)
            exit()
        else:
            ans[s-1] = c

    if ans[0] == -1:
        ans[0] = 1

for i in range(N):
    if ans[i] == -1:
        ans[i] = 0

[print(i,end='') for i in ans]


Measured memory_bytes: 3064
N, M = map(int, input().split())

ac = wa = 0
ac_lis = [False] * N
wa_cnt = [0] * N
for _ in range(M):
  p, s = input().split()
  p = int(p) - 1

  if s == "AC":
    if not ac_lis[p]:
      ac += 1
      wa += wa_cnt[p]
      ac_lis[p] = True
  else:
    if not ac_lis[p]:
      wa_cnt[p] += 1

print(ac, wa)


Measured memory_bytes: 77292