akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int ans[s.size()] = {};
    int i = 0;
    while(i < s.size()){
        int cnt_R = 0, cnt_L = 0;
        while(s[i] == 'R'){
            cnt_R++;
            i++;
        }
        int mem = i;
        while(s[i] == 'L'){
            cnt_L++;
            i++;
        }
        if((cnt_L + cnt_R) % 2 == 0){
            ans[mem - 1] = (cnt_L + cnt_R) / 2;
            ans[mem] = (cnt_L + cnt_R) / 2;
        }else{
            if(cnt_R <= cnt_L){
                if(cnt_L % 2 == 1){
                    ans[mem - 1] = (cnt_L + cnt_R) / 2;
                    ans[mem] = (cnt_L + cnt_R) / 2 + 1;
                }else{
                    ans[mem - 1] = (cnt_L + cnt_R) / 2 + 1;
                    ans[mem] = (cnt_L + cnt_R) / 2;
                }
            }else{
                if(cnt_R % 2 == 1){
                    ans[mem - 1] = (cnt_L + cnt_R) / 2 + 1;
                    ans[mem] = (cnt_L + cnt_R) / 2;
                }else{
                    ans[mem - 1] = (cnt_L + cnt_R) / 2;
                    ans[mem] = (cnt_L + cnt_R) / 2 + 1;
                }
            }
        }
    }
    REP(i,s.size()){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		Long answer = (long) 1;
		int pow = (int)(Math.pow(10, 9) + 7);

		for(int i=1; i<=n; i++){
			answer = answer * i;
			answer = answer % pow;
		}
		System.out.println(answer);

	}

}


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

signed main(){
	lint N, sum = 0;
	cin >> N;
	vector<lint> a(N);
	for(lint i = 0; i < N; i++) cin >> a[i], sum += abs(a[i]);
	sort(a.begin(), a.end());
	if(a[0] > 0) sum -= a[0] * 2;
	if(a.back() < 0) sum += a.back() * 2;
	cout << sum << endl;
	lint x = a[0];
	for(lint i = 1; i < N - 1; i++){
		if(a[i] >= 0){
	 	  cout << x << " " << a[i] << endl;
		  x -= a[i];
		}
	}
	cout << a.back() << " " << x << endl;
	x = a.back() - x;
	for(lint i = 1; i < N - 1; i++){
		if(a[i] < 0){
			cout << x << " " << a[i] << endl;
			x -= a[i];
		}
	}
}

Measured memory_bytes: 2688
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll T = 0;
	//ll M = 0;
	ll h[1000] = {};
	ll b[100] = {};
	//ll c[100] = {};
	//ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	float sum = 0;
	ll min = 1000000000000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	//int flag = 0;
	char temp,head;
	//int is = 0;
	bool flag = false;
	
	//char p;


	

	

	//cin >> S;
	
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);
	
	cin >> N;
	
	vector<int> ch(N);


	rep(i, 0, N) {
		cin >> ch[i];
	}

	sort(ch.begin(), ch.end());

	rep(i, 0, N) {

		if (i == (N - 1))
			ch[i] /= 2;

		sum += ch[i];

		//cout << ch[i] << endl;
	}

	

	
		cout << sum << endl;

	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	//cin >> N >> M;

	//vector<pair<int,int>> c(M);
	////vector<pair<int, int>> e(M);
	//vector<ll> d(M);

	//rep(i, 0, M) {
	//	cin >> c[i].first >> c[i].second;
	//	//e[i].first = c[i].first;
	//	//e[i].second = c[i].second;

	//}
	////sort(c.begin(), c.end());

	//

	//rep(i, 0, M) {

	//	
	//	
	//	rep(j, 0, M) {
	//		if (c[i].first == c[j].first && c[j].second < c[i].second) {
	//			d[i]++;
	//			//cout << j << endl;
	//		}
	//	}
	//	cout << std::setfill('0') << std::right << std::setw(6) << c[i].first;
	//	cout << std::setfill('0') << std::right << std::setw(6) << d[i]+1 << endl;
	//}

	return 0;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   long long int a,b;
   char c;
   cin>>a>>c>>b;
   if(c=='+')
    cout<<a+b;
else
    cout<<a-b;
   
    return 0;
}








Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  ll a[N], b[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];

  ll asum, bsum;
  asum = bsum = 0;
  for (int i = 0; i < N; i++) {
    asum += a[i], bsum += b[i];
  }

  ll diff = bsum - asum;
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    ll d = b[i] - a[i];
    if (d < 0) continue;

    cnt += (d + 1) / 2;
  }

  // 解答
  cout << (cnt <= diff ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char s[100010];
    scanf("%s", s);
    int len = strlen(s);
    int p[27];
    memset(p, 0, sizeof(p));
    int i;
    for(i = 0; i < len; i++)
    {
        p[s[i]-'a']++;
    }
    int num = 0;
    for(i = 0; i < 26; i++)
    {
        if(p[i] > 1)
        {
            num++;
        }
    }
    if(s[0] == s[len - 1])
    {
        if(len % 2 == 1)
        {
            printf("Second\n");
        }
        else printf("First\n");
    }
    else
    {
        if(len % 2 == 1)
        {
            printf("First\n");
        }
        else printf("Second\n");
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
B = itertools.groupby(A)
cnt1 = 0
cnt2 = 0
for key, group in B:
    if len(list(group))%2==1:
      cnt1+=1
    else:
      cnt2+=1
print(cnt1+cnt2//2*2)

Measured memory_bytes: 56004
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            if (n == 0 && w == 0) break;
            var a = new int[100];
            var pmax = 0;
            var amax = 0;
            for (int i = 0; i < n; i++)
            {
                var te = int.Parse(Console.ReadLine().Trim()) / w;
                a[te]++;
                amax = Math.Max(amax, a[te]);
                pmax = Math.Max(pmax, te);
            }
            var res = 0.01d;
            for (int i = 0; i < pmax; i++)
                res += (double)(pmax - i) * a[i] / (amax * pmax);
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 7924
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        S: chars,
        T: chars,
    }
    let mut ans = 10000;
    for start in 0..=S.len() - T.len() {
        let mut acc = 0;
        for st in 0..T.len() {
            if T[st] != S[start + st] {
                acc += 1;
            }
        }
        ans = min(ans, acc)
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
    int n,m;

    while(cin>>n, n) {
        map<int,int> dap;

        string name[21];
        int d[21][31], m[21];
        for(int i=0; i<n; ++i) {
            cin>>name[i]>>m[i];
            for(int j=0; j<m[i]; ++j) {
                cin>>d[i][j];
                if(dap.find(d[i][j]) == dap.end()) dap[d[i][j]] = 1;
                else dap[d[i][j]]++;
            }
        }


        int minp = 1<<29;
        string ans = "";
        for(int i=0; i<n; ++i) {
            int tp = 0;
            for(int j=0; j<m[i]; ++j) {
                tp += n - dap[d[i][j]] + 1;
            }
            if(tp < minp) {
                ans = name[i];
            }else if(tp == minp && ans > name[i]) {
                ans = name[i];
            }
            minp = min(minp, tp);
        }

        cout<<minp<<" "<<ans<<endl;
    }
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000000+7;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
#define print(s) cout<<s<<endl
#define input(s) cin>>s
ll x, y, x2, y2;
int main() {
	input(x >> y >> x2 >> y2);
	print(string(y2-y,'U')<<string(x2-x,'R')<<string(y2-y,'D')<<string(x2-x,'L')
		<<"L"<<string(y2-y+1,'U')<<string(x2-x+1,'R')<<"D"
		<<"R"<<string(y2-y+1,'D')<<string(x2-x+1,'L')<<"U");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct sub{
 int wa;
 bool ac = false;
};
int main(){
int n , m;
cin>>n>>m;
map<int,sub> scores;
int input = 0;
string re ;
int c1 , c2 ;
c1 = c2 =0;
for(int i = 0 ; i < m ; i++){
    cin>>input>>re;
    if(re == "WA"){
    if(!scores[input].ac){
    scores[input].wa++;
    c2++;
    }
    }else{
      if(!scores[input].ac){
          scores[input].ac = true;
          c1++;
      }
    }
}
c1 = c2 = 0;
for(auto element : scores){
  if(element.second.ac){
      c1++;
      c2+=element.second.wa;
  }
}
cout<<c1<<" "<<c2<<endl;
return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}


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

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

signed main() {
    int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }

    int dp[10001] = {};
    for (int i = 0; i < M; i++) {
        dp[num[A[i]]] = 1;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < M; j++) {
            if (i > num[A[j]]) {
                if (dp[i] <= dp[i - num[A[j]]] + 1) {
                    dp[i] = dp[i - num[A[j]]] + 1;
                }
            }
        }
        if (dp[i] == 0) dp[i] = -1000;
    }

    sort(A.begin(), A.end(), greater<int>());
    string ans = "";
    while (N > 0) {
        for (int i = 0; i < M; i++) {
            if (N - num[A[i]] >= 0) {
                if (dp[N - num[A[i]]] != -1000 && dp[N - num[A[i]]] == dp[N] - 1) {
                    ans += to_string(A[i]);
                    N -= num[A[i]];
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        string S, T;
        cin >> S >> T;
        sort(S.begin(), S.end());
        sort(T.begin(), T.end());
        reverse(T.begin(), T.end());

        if (S < T)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;

        return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.TreeMap;
import java.util.*;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt();
        int b = fs.nextInt();
        int c = fs.nextInt();

        if (b - a == c - b)
            System.out.println("YES");
        else
            System.out.println("NO");
    }

}


Measured memory_bytes: 79828
n = gets.to_i
A = gets.split.map(&:to_i)

num1 = 0
sum1 = 0
A.each_with_index do |a, i|
  sum1 += a
  # +, -, +, -
  if i % 2 == 0
    # +
    if sum1 > 0
      next
    else
      num1 += (1 - sum1).abs
      sum1 = 1
    end
  else
    # -
    if sum1 < 0
      next
    else
      num1 += (-1 - sum1).abs
      sum1 = -1
    end
  end
end

num2 = 0
sum2 = 0
A.each_with_index do |a, i|
  sum2 += a
  # -, +, -, +
  if i % 2 == 0
    # -
    if sum2 < 0
      next
    else
      num2 += (-1 - sum2).abs
      sum2 = -1
    end
  else
    # +
    if sum2 > 0
      next
    else
      num2 += (1 - sum2).abs
      sum2 = 1
    end
  end
end

puts [num1, num2].min


Measured memory_bytes: 8588
#include<iostream>
#include<vector>
#include<complex>

using namespace std;

typedef complex<double> P;
typedef vector<P> Polygon;

double cross(P a,P b){
  return (conj(a)*b).imag();
}

//line,line
P intersection(P a1,P a2,P b1,P b2){
  P a=a2-a1;
  P b=b2-b1;
  return a1+a*cross(b,b1-a1)/cross(b,a);
}

//a->b keep leftside points
Polygon cut(P a,P b,const Polygon &p){
  int n=p.size();
  vector<double> c(n);
  for(int i=0;i<n;i++){
    c[i]=cross(b-a,p[i]-a);
  }
  Polygon r;
  for(int i=0;i<n;i++){
    if(c[i]>=0){
      r.push_back(p[i]);
    }
    if(c[i]*c[(i+1)%n]<0){
      r.push_back(intersection(a,b,p[i],p[(i+1)%n]));
    }
  }
  return r;
}

double area(const Polygon &p){
  double a=0;
  for(int i=0;i<p.size();i++){
    a+=cross(p[(i+1)%p.size()],p[i]);
  }
  return fabs(a)/2;
}


int main(){
  for(int t=1;;t++){
    P p[3];
    bool f=false;
    for(int i=0;i<3;i++){
      int x,y;
      cin>>x>>y;
      if(x==0)return 0;
      p[i]=P(x,y);
    }
    Polygon pg{P(0,0),P(0,10000),P(10000,10000),P(10000,0)};
    for(int i=1;i<=2;i++){
      P m=(p[0]+p[i])/2.;
      pg=cut(m,m+(p[i]-p[0])*P(0,1),pg);
    }
    cout.precision(9);
    cout<<t<<' '<<fixed<<area(pg)/1e8<<endl;
  }
}

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<numeric>
#include<map>
#include<set>

int const MAXN = 2e5;
int a[MAXN], b[MAXN], N, k;
int c[MAXN-1], d[MAXN+MAXN-2];
int rank[MAXN+MAXN-1];
int tmp[MAXN+MAXN-1];
int sa[MAXN+MAXN-1];

bool comp_sa(int i, int j) {
  if(rank[i]!=rank[j]) return rank[i] < rank[j];
  int ri = i+k <= N+N-2? rank[i+k]: -1;
  int rj = j+k <= N+N-2? rank[j+k]: -1;
  return ri < rj;
}

int main() {
  std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  for(int i = 0; i < N; ++i) std::cin >> b[i];
  for(int i = 0; i < N-1; ++i) c[i] = a[i]^a[i+1];
  for(int i = 0; i < 2*N-2; ++i) d[i] = b[i%N]^b[(i+1)%N];
  std::set<int> ans;
  // SA
  std::copy_n(d, 2*N-2, rank); rank[2*N-2] = -1;
  std::iota(sa, sa+2*N-1, 0);
  for(k = 1; k <= 2*N-2; k += k) {
    std::sort(sa, sa+2*N-1, comp_sa);
    tmp[sa[0]] = 0;
    for(int i = 1; i <= 2*N-2; ++i) {
      tmp[sa[i]] = tmp[sa[i-1]] + (comp_sa(sa[i-1], sa[i])? 1: 0);
    }
    std::copy_n(tmp, 2*N-1, rank);
  }
  int lb = std::partition_point(sa, sa+2*N-1, [&](int i) {
    // d[i, 2*N-2) < c[0, N-1)
    for(int j = 0; j+i < 2*N-2 && j < N-1; ++j) {
      if(d[j+i] != c[j]) return d[j+i] < c[j];
    }
    return 2*N-2-i < N-1;
  }) - sa;
  int ub = std::partition_point(sa, sa+2*N-1, [&](int i) {
    // d[i, 2*N-2) < c[0, N-1) or d[i, i+N-1) == c[0, N-1)
    for(int j = 0; j+i < 2*N-2 && j < N-1; ++j) {
      if(d[j+i] != c[j]) return d[j+i] < c[j];
    }
    return true;
  }) - sa;
  for(int i = lb; i < ub; ++i) {
    ans.insert((N-sa[i])%N);
  }
  // ans
  for(auto k: ans) {
    int x = a[0]^b[(N-k)%N];
    std::cout << k << " " << x << std::endl;
  }
  return 0;
}



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

int main() {
    int a, b, c, d, e, k;
  	cin >> a >> b >> c >> d >> e >> k;
  	cout << ((max({a, b, c, d, e}) - min({a, b, c, d, e}) > k) ? ":(" : "Yay!") << endl;
}

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

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

int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i, 4)cout << s[i];
	cout << " ";
	rep(i, 8)cout << s[i + 4];
	cout << endl;
	return 0;
}

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

int main() {
  ll a, b; cin >> a >> b;
  ll ans;
  ll n1;
  if (a%2==0 && b%2==1) {
    n1 = (b+1-a)/2;
    if (n1 % 2 == 0) {ans = 0;}
    if (n1 % 2 == 1) {ans = 1;}
  }
  if (a%2==0 && b%2==0) {
    n1 = (b-a)/2;
    if (n1 % 2 == 0) {ans = b;}
    if (n1 % 2 == 1) {ans = b^1;}
  }
  if (a%2==1 && b%2==1) {
    n1 = (b-a)/2;
    if (n1 % 2 == 0) {ans = a;}
    if (n1 % 2 == 1) {ans = a^1;}
  }
  if (a%2==1 && b%2==0) {
    n1 = (b-a-1)/2;
    if (n1 % 2 == 0) {ans = a^b;}
    if (n1 % 2 == 1) {ans = a^b^1;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int c[5][14];
    for (int i=1;i<=4;i++){
        for (int j=1;j<=13;j++){
            c[i][j]=0;
        }
    }
    for (int i=1;i<=n;i++){
        char a;
        int b;
        cin>>a>>b;
        if(a=='S'){
            c[1][b]=1;
        } 
        else if(a=='H') {
            c[2][b]=1;
        }
        else if(a=='C'){
            c[3][b]=1;
        } 
        else if(a=='D'){
            c[4][b]=1;
        }
    }
    for (int i=1;i<=13;i++){
        if(c[1][i]!=1){
            cout<<"S"<<" "<<i<<endl;
        }
    }
    for (int i=1;i<=13;i++){
        if(c[2][i]!=1){
            cout<<"H"<<" "<<i<<endl;
        }
    }
    for (int i=1;i<=13;i++){
        if(c[3][i]!=1){
            cout<<"C"<<" "<<i<<endl;
        }
    }
    for (int i=1;i<=13;i++){
        if(c[4][i]!=1){
            cout<<"D"<<" "<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[3];
int main() {
	ll n;
	cin>>n;
	ll ans=1;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		ll cnt=0;
		bool CH=false;
		for(ll j=0;j<3;j++){
			if(ch[j]==now){
				cnt++;
				if(CH==false){
					ch[j]++;
					CH=true;
				}
			}
		}
		ans*=cnt;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

#[fastout]
fn main() {
  input! {
    n: i32,
  }
  for x in 1.. {
    if x > n {
      break;
    }
    let rest = x * 8 / 100;
    if x + rest == n {
      println!("{}", x);
      return;
    }
  }
  println!(":(");
}


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


ll comb[3005][3005];
int n;
ll MOD;
// stl_sec(i,j) means tne number of ways divide exactly i elements divide by j groups 
ll stl_sec[3005][3005];
// ways2(i,j) means the number of ways "some" of i elements divide by j groups
ll ways2[3005][3005];
ll ways[3005];
ll twop[20000005];

ll mod_pow(ll x,ll n,ll m=MOD){
	ll ans=1;
	while(n>0LL){
		if(n&1LL)ans=ans*x%m;
		x=x*x%m;
		n>>=1LL;
	}
	return ans;
}

void init(){
	twop[0]=1;
	for(int i=1;i<=20000004;i++){
		twop[i]=twop[i-1]*2LL%MOD;
	}
	comb[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=1;j<i;j++){
			comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%MOD;
		}
		comb[i][0]=1;
		comb[i][i]=1;
	}
}

int main(void){
	scanf("%d%lld",&n,&MOD);
	init();
	stl_sec[0][0]=1;
	for(int i=0;i<=n+1;i++){
		for(int j=1;j<=i;j++){
			stl_sec[i][j]=(stl_sec[i-1][j-1]+stl_sec[i-1][j]*j)%MOD;
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			ways2[i][j]=stl_sec[i+1][j+1]*twop[(n-i)*j]%MOD;
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			ways[i]=(ways[i]+ways2[i][j])%MOD;
		}
	}
	ll ans=0;
	ll po=1;
	for(int i=0;i<=n;i++){
		ans+=((mod_pow(2,mod_pow(2,n-i,MOD-1LL))*comb[n][i]%MOD)*ways[i]%MOD)*po;
		if(ans<0LL)ans+=MOD;
		ans%=MOD;
		po*=-1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 368128
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int histArea(vector<int> h) {
    // 番兵
    int N = h.size();
    h.push_back(0); N++;

    // height, position
    int ans = 0;
    stack<pii> S;
    rep(i,0,N+1) {
        if(S.empty()) S.push(pii(h[i], i));

        if     (S.top().first < h[i])
            S.push(pii(h[i], i));
        else if(S.top().first > h[i]) {
            int lastpos = 0;
            while(!S.empty() && S.top().first >= h[i]) {
                lastpos = S.top().second;
                chmax(ans, S.top().first * (i-lastpos+1));
                S.pop();
            }
            S.push(pii(h[i], lastpos));
        }
    }
    return ans;
}

int maxRectangle(vector< vector<int> > board) {
    int H = board.size(), W = board[0].size();
    vector< vector<int> > sum(H, vector<int>(W));
    rep(i,0,H) rep(j,0,W) {
        if(board[i][j] == 1) sum[i][j] = 1;
        else sum[i][j] = (i > 0 ? sum[i-1][j] : 0) + 1;
    }
    int ret = 0;
    rep(i,0,H) chmax(ret, histArea(sum[i]));
    return ret;
}

int H, W;
char board[2010][2010];
int dx[] = {0, 0, -1, -1};
int dy[] = {0, 1, 0, 1};
signed main() {
    cin >> H >> W;
    rep(i,0,H) rep(j,0,W) cin >> board[i][j];

    vector< vector<int> > v(H, vector<int>(W-1));
    rep(i,1,H) rep(j,0,W-1) {
        int cnt = 0;
        rep(k,0,4) {
            int nx = i + dx[k], ny = j + dy[k];
            if(board[nx][ny] == '#') cnt++;
        }
        if(cnt % 2) v[i][j] = 1;
    }
    cout << max(max(H, W), maxRectangle(v)) << endl;
    return 0;
}

Measured memory_bytes: 100096
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define ll long long
#define int long long
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
using namespace std;
    
const int N=200000+10,inf=1e18;
int n,q,pre,nw,tag[N<<2];
ll tr1[N<<2],tr2[N<<2];
 
il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
void pushdown(ri nw)
{
	if(!tag[nw])return;
	tag[nw<<1]+=tag[nw];tag[nw<<1|1]+=tag[nw];
	tr1[nw<<1]+=tag[nw];tr1[nw<<1|1]+=tag[nw];
	tr2[nw<<1]+=tag[nw];tr2[nw<<1|1]+=tag[nw];
	tag[nw]=0;
}
void modify(ri nw,ri l,ri r,ri to,ll dat)
{
	if(l==r){tr1[nw]=min(tr1[nw],dat-to),tr2[nw]=min(tr2[nw],dat+to);return;}
	pushdown(nw);ri mid=(l+r)>>1;to<=mid?modify(nw<<1,l,mid,to,dat):modify(nw<<1|1,mid+1,r,to,dat);
	tr1[nw]=min(tr1[nw<<1],tr1[nw<<1|1]);tr2[nw]=min(tr2[nw<<1],tr2[nw<<1|1]);
}
ll query1(ri nw,ri l,ri r,ri to_l,ri to_r)
{
	if(to_l<=l && r<=to_r)return tr1[nw];
	pushdown(nw);ri mid=(l+r)>>1;ll ret=inf;
	if(to_l<=mid)ret=query1(nw<<1,l,mid,to_l,to_r);
	if(mid<to_r)ret=min(ret,query1(nw<<1|1,mid+1,r,to_l,to_r));
	return ret;
}
ll query2(ri nw,ri l,ri r,ri to_l,ri to_r)
{
	if(to_l<=l && r<=to_r)return tr2[nw];
	pushdown(nw);ri mid=(l+r)>>1;ll ret=inf;
	if(to_l<=mid)ret=query2(nw<<1,l,mid,to_l,to_r);
	if(mid<to_r)ret=min(ret,query2(nw<<1|1,mid+1,r,to_l,to_r));
	return ret;
}
ll query(ri nw,ri l,ri r)
{
	if(l==r)return tr1[nw]+l;
	pushdown(nw);ri mid=(l+r)>>1;return min(query(nw<<1,l,mid),query(nw<<1|1,mid+1,r));
}

signed main() 
{
//	freopen("2558.in","r",stdin);
    n = read(), q = read(), pre = read();memset(tr1, 63, sizeof(tr1));memset(tr2, 63, sizeof(tr2));modify(1,1,n,read(),0);
    while(q--)
	{
        int nw=read();ll dat=min(query1(1,1,n,1,nw)+nw,query2(1,1,n,nw,n)-nw);
        tag[1]+=abs(nw-pre);tr1[1]+=abs(nw-pre);tr2[1]+=abs(nw-pre);modify(1,1,n,pre,dat);
        pre=nw;
    }
    printf("%lld\n",query(1,1,n));
	return 0;
}

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

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        int K = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        if (K < S.Length)
        {
            Console.WriteLine(S.Substring(0,K)+ "...");
        }
        else
        {
            Console.WriteLine(S);
        }
      //  Console.ReadLine();
    }

}

Measured memory_bytes: 27412
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let v: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    // 価値の小さい具材から順に鍋に入れればよい
    let u = {
        let mut u = v.clone();
        u.sort();
        u
    };
    let ans = u[1..].iter()
        .map(|&x| x as f64)
        .fold(u[0] as f64, |acc, x| (acc + x) / 2.0);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,t;
    cin>>n>>t;
    vector<ll> ti(n);
    ll ans=0;
    rep(i,n){
        cin>>ti[i];
        if(i!=0) ans+=min(t,ti[i]-ti[i-1]);
    }
    ans+=t;
    cout<<ans;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1000000007;

// B[i] corresponds to i-th stair
// B is 0-indexed
int *Flag(int *A, int n)
{
  int *B;
  B = (int*)malloc(sizeof(int)*(n+1));
  int i,j;
  i = 0;
  j = 0;
  for(i = 0; i <= n ; i++){
    if(A[j] == i){ // i-th stair is broken
      B[i] = 0;
      j++;
    } else {
      B[i] = 1;
    }
  }
  return B;
}

// B[0],...,B[n] are given
void count_way(int *B,int n)
{
  if(n==1){
    cout << 1 << endl;
    return;
  }
  ll *C;
  C = (ll*)malloc(sizeof(ll)*(n+1));
  C[0] = 1; // ground
  C[1] = B[1];
  for(int i=2; i<=n;i++){
    C[i] = B[i]*(C[i-2] + C[i-1])%N;
  }
  cout << C[n] << endl;
}

int main()
{
  ll n,m;
  int *A;
  cin >> n >> m;
  A = (int*)malloc(sizeof(int)*m);
  for(int i=0; i<m; i++){
    cin >> A[i];
  }
  int *B;
  B = Flag(A,n);
  count_way(B,n);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

double distance(vector<int> x, vector<int>y){
  int sum_sq = 0;
  REP(i, x.size()){
    sum_sq += pow(x.at(i) - y.at(i), 2);
  }
  return sqrt(sum_sq);
}

signed main() {
  IOS
  // INTXT
  int n, d;
  cin >> n >> d;

  vector<vector<int>> points(n);
  REP(i, n){
    REP(j, d){
      int x;
      cin >> x;
      points.at(i).push_back(x);
    }
  }
  
  int cnt = 0;
  REP(i, n){
    FOR(j, i + 1, n){
      double d = distance(points.at(i), points.at(j));
      if (floor(d) == d){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,S,T,i,la,now,f[200001],a[200001];
int main(){
	scanf("%lld%lld%lld",&n,&S,&T);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	la=0;now=1e9;
	for(i=1;i<=n;i++){
		while(la<i&&2*(a[i]-a[la+1])>T){
			now=min(now,f[la]-2*a[la+1]);
			la++;
		}
		f[i]=min(2*a[i]+now,f[la]+T);
	}
	f[n]+=a[n]+abs(a[n]-S);
	printf("%lld",f[n]);
}
/*
最后肯定被分成一段段 
*/

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {

        int k=0;
        int n=0;
        int x_price = 0;
        int y_price = 0;

        cin >> n >> k >> x_price >> y_price;

        int total = 0;
        for (int i = 0; i < n; ++i) {

                if (i < k) {
                        total += x_price;
                }
                else {
                        total += y_price;
                }
        }
        cout << total << endl;

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char a[5][3]={ "a", "e", "i", "o", "u"};
	string s;
	cin>>s;
	for(int i=0;i<5;i++){
		if(a[i]==s) {
			cout<<"vowel"<<endl;
			return 0;
		}
	}
	cout<<"consonant"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define N 20
#define M 200
int n,a[N];
int solve(int,int);
int main(){
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  if(m==0){
    return 1;
  }
  if(i>=n) return 0;
  int res = solve(i+1,m)||solve(i+1,m-a[i]);
  return res;
}


Measured memory_bytes: 2052
#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<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll an,bn,m;
cin>>an>>bn>>m;
ll a[an],b[bn];
ll at[an],bt[bn];
ll x,y,c;
for(int i=0;i<an;i++){
    cin>>a[i];
    at[i]=a[i];
}
for(int i=0;i<bn;i++){
    cin>>b[i];
    bt[i]=b[i];
}
sort(a,a+an);
sort(b,b+bn);
ll ans=a[0]+b[0];
for(int i=0;i<m;i++){
    cin>>x>>y>>c;
    chmin(ans,at[x-1]+bt[y-1]-c);
}
cout<<ans<<endl;
}









Measured memory_bytes: 3328
#include <stdio.h>

void swap(long *a, long *b){
  long tp;
  tp=*a;
  *a=*b;
  *b=tp;
  return;
}

int isprime(long n){
  long i;
//  if(n<=2)return 1;
  for(i=547;i*i<=n;i++){
    if(n%i==0) return 0;
  }
  return 1;
}

int main()
{
  long a,b,newa,newb,i;
  int idx;
  int ans;
  scanf("%ld%ld", &a,&b);
  if(a<b) swap(&a,&b);
  while(newb=a%b){
    a=b;
    b=newb;
  }
//  long lcd=b;
  ans=1;
  i=2;
  while(i*i<=b){
    if(b%i==0){
      ans++;
      while(b%i==0) b/=i;
    }
    i++;
  }
  if(b>1) ans++;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
n=int(input())

def xor(x,y):
    return ((x and y) or (not (x or y)))

def change(x):
    da=[True for i in range(31)]
    for i in da:
        da[i]=bool(x%2)
        x/=2
    return da

da=list(map(int,input().split()))
di={}
ans=False
for i in da:
    if i in di.keys():
        di[i]+=1
    else:
        di[i]=1
va=list(di.values())
ke=list(di.keys())
if len(di)==3:
    if va[0]==va[1] and va[0]==va[2]:
        if ke[0]^ke[1]==ke[2]:
            ans=True
elif len(di)==2:
    if va[0]==va[1]*2 or va[1]==va[0]*2:
        if ke[0]==0 or ke[1]==0:
            ans=True

elif len(di)==1:
    if ke[0]==0:
        ans=True
if ans:
    print('Yes')
else:
    print('No')
    


Measured memory_bytes: 14212
#include <iostream>
#include <cmath>

using namespace std;
long x;

int main() {
    cin >> x;
    for (int a = -120; a < 120; a++) {
        for (int b = -120; b < 120; b++) {
            if (pow(a, 5) - pow(b, 5) == x) {
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
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 main() {
    int n; cin >> n;
    vector<int> cnt(n*10, 0);
    int limit = sqrt(n) + 1;
    for(int x = 1; x < limit; ++x) {
        for(int y = 1; y < limit; ++y) {
            for(int z = 1; z < limit; ++z) {
                int sum = pow(x, 2) + pow(y, 2) + pow(z, 2);
                sum += (x*y + y*z + z*x);
                cnt.at(sum)++;
            }
        }
    }

    for(int i = 1; i <= n; ++i) {
        cout << cnt.at(i) << endl;
    }
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

    int sum = 0;
    rep(i, n) sum += t[i];
    rep(i, m){
        int p, x;
        cin >> p >> x;
        p--;
        int ans = sum + x - t[p];
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
/*
 * Created by: Son Dinh
 */ 
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define sz(X) (int)(X).size()
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int mod=1e9+7;

int a,b,res;
int main(){
    scanf("%d %d",&a,&b);
    for(int i=1;i<=2;++i){
        if(a>b){
            res+=a;
            a--;
        }else{
            res+=b;
            b--;
        }
    }
    printf("%d",res);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,K;
    cin >> N >> K;
    ll m1 = N % K;
    ll m2 = abs(m1 - K);
    cout << min(m1,m2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
using namespace std;

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

int main () {

    int n; cin >> n;
    vector < int > P(n);
    REP(i,n) cin >> P[i];

    vector < pair < int,int > > ord;
    REP(i,n) ord.push_back(make_pair(P[i], i));
    sort(ord.begin(), ord.end());

    int ans = 1;
    int cnt = 1;
    REP(i,n - 1) {
        if (ord[i].second < ord[i + 1].second) {
            cnt++;
        } else {
            cnt = 1;
        }
        ans = max(ans, cnt);
    }

    cout << n - ans << endl;

    return 0;
}


Measured memory_bytes: 3188