akhauriyash/Code-Regression huggingface dataset:
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const alpha = input[0][0];

  return alpha === alpha.toUpperCase() ? "A" : "a";
};

console.log(main(read()));


Measured memory_bytes: 29672
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;




void solve() {
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(4);
	//init();
	solve();
	stop
		return 0;
}


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

int main(void){
  long long int k, a, b;
  cin >> k >> a >> b;

  if(a >= k){ cout << 1 << endl; }
  else if(a <= b){ cout << -1 << endl; }
  else{
    long long int rating = a;
    long long int diff = a - b;
    long long int ans = (k - rating + diff - 1) / diff;
    ans = ans * 2 + 1;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		for (int i = 0; i < arr.length; i++) {
			if (i % 2 == 0) {
				if (arr[i] == 'L') {
					System.out.println("No");
					return;
				}
			} else {
				if (arr[i] == 'R') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
long long n, a[25][25], dp[3000000], mod=1000000007;
long long solve (long long bitmask){
	if (dp[bitmask]!=-1) return dp[bitmask];
	dp[bitmask]=0;
	for (int i=0; i<n; i++){
		if (bitmask&(1LL<<i) and a[i][__builtin_popcount(bitmask)]){
			dp[bitmask]+=solve(bitmask^(1LL<<i));
		}
	} dp[bitmask]%=mod;
	return dp[bitmask];
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=0; i<n; i++){
	for (int j=1; j<=n; j++){
		cin >> a[i][j];
	}
}
for (int i=0; i<=1<<n; i++) dp[i]=-1; dp[0]=1;
cout << solve((1LL<<n)-1);
return 0;
}


Measured memory_bytes: 20028
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll conH(ll cx,ll cy,ll x,ll y,ll h){
  return h+abs(cx-x)+abs(cy-y);
}

ll geth(ll cx,ll cy,ll x,ll y,ll H){
  return max(H-abs(cx-x)-abs(cy-y),(ll)0);
}

bool solve(){
  ll n;cin>>n;
  vector<ll>x(n);
  vector<ll>y(n);
  vector<ll>h(n);
  rep(i,n)cin>>x[i]>>y[i]>>h[i];
  rep(cx,101)rep(cy,101){
    ll H;
    rep(i,n){
      if(h[i]!=0){
        H=conH(cx,cy,x[i],y[i],h[i]);
        break;
      }
    }
    bool isOK=true;
    rep(i,n){
      if(geth(cx,cy,x[i],y[i],H)!=h[i]){
        isOK=false;
      }
    }
    if(isOK){
      cout<<cx<<" "<<cy<<" "<<H<<endl;
      return false;
    }
  }
  return false;
}

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


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	k := scanInt()

	combInit(n)

	ans := 0
	for i := 0; i <= k; i++ {
		tmp := m * mpow(m-1, n-1-i) % mod * comb(n-1, i) % mod
		// debug(tmp,comb(n-1, i))
		ans += tmp
		ans %= mod
	}
	fmt.Fprintln(wr, ans)
}

const mod = 998244353

var fac, ifac, inv []int

func combInit(n int) {
	fac = make([]int, n+1)
	ifac = make([]int, n+1)
	inv = make([]int, n+1)

	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[1] = 1

	for i := 1; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % mod
		inv[i+1] = mod - inv[mod%(i+1)]*(mod/(i+1))%mod
		ifac[i+1] = ifac[i] * inv[i+1] % mod
	}
}

func comb(a, b int) int { return (fac[a] * ifac[b] % mod) * ifac[a-b] % mod }
func perm(a, b int) int { return fac[a] * ifac[a-b] % mod }

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}


Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
int A[200][200],b[200],ap[200][200];
int main()
{
    string ans="No";
    int i,j,n,k,cnt=0,m;
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
            cin>>A[i][j];
    }
    cin>>k;
    for(i=0; i<k; i++)
        cin>>b[i];
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
             for(m=0; m<k; m++)
             {
                 if(b[m]==A[i][j])
                    {
                        ap[i][j]=1;
                    }
             }
        }
    }
      for(i=0; i<3; i++)
      {
          if((ap[i][0]==1&& ap[i][1]==1&& ap[i][2]==1)||(ap[0][i]==1&& ap[1][i]==1&& ap[2][i]==1))
            ans="Yes";
      }
 
    if((ap[0][0]==1&& ap[1][1]==1&& ap[2][2]==1) ||(ap[0][2]==1&& ap[1][1]==1&& ap[2][0]==1)) ans="Yes";
        cout<<ans<<"\n";
 
    return 0;
}

Measured memory_bytes: 256
cal d =
  let s  = sum d
      mx = maximum d
      mn = minimum d
      l  = (length d) - 2
  in
    (s - mx - mn) `div` l

ans (0:_) = []
ans (n:ns) =
  let a = cal $ take n ns
      r = drop n ns
  in
    a:(ans r)

main = do
  c <- getContents
  let i = map read $ lines c :: [Int]
      o = ans i
  mapM_ print o



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

using namespace std;

int N;

int T[1000];
int C[1000];
int S[1000];

int main(void) {
    cin>>N;

    for(int i = 1;i < N;i++) {
        int c,s,f;
        cin>>c>>s>>f;
        T[i] = f;
        C[i] = c;
        S[i] = s;    
    }

    for(int i = 1;i < N;i++) {
        int t = S[i]+C[i];
        for(int j = i+1;j < N;j++) {
            if(t < S[j])
                t = S[j];
            while(t % T[j] != 0)
                t++;
            t += C[j];
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        int n=sc.nextInt();

        int a[] = new int[n];
        int b[] = new int[n];
        
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++) {
            b[i] = sc.nextInt();
        }
   
        int c[] = new int[n];
        int ans=0;
        for(int i=0; i<29; i++) {

            int md = (1<<(i+1));
            for(int t=0; t<n; t++) {
                c[t] = b[t]&(md-1);
            }

            Arrays.sort(c);
            int bit=0;

            for(int t=0; t<n; t++){ 
                int  at=a[t]%md, l = -at + (1<<i), r = -at + (1<<(i+1));

                l=lb(c,l);
                r=lb(c,r)-1;
                if(l<n)bit^=(r-l+1)%2;

                l = -at + (3<<(i)); r = -at + (1<<(i+2));
                l=lb(c,l);
                r=lb(c,r)-1;

                if(l<n)bit^=(r-l+1)%2;
            }
            ans^=bit<<i;
        }

        out.println(ans);
        out.flush();
    }

    static int lb(int[] a, int x) {
        int l = -1, r = a.length;
        while (r-l > 1) {
            int md = (l+r)/2;
            if (a[md] < x) {
                l = md;
            } else {
                r = md;
            }
        }
        return r;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        int id, d;
        P(int  id, int d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return d-p.d; //descend
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define test() ll t;cin>>t;for(ll test = 1;test<=t;test++)
#define f first
#define s second
#define pb push_back
#define ins insert
#define nl cout<<"\n"
#define P 1000000007
#define N 100005
#define MOD(x) ((x%P)+P)%P
#define show(x) cout<<x<<" "
#define vec(v) loop(i,0,v.size()) show(v[i]); nl

int len[N];
bool vis[N];
vector <int> gr[N];

int dfs(int node)
{
	if(vis[node])
		return len[node];
	vis[node] = 1;

	int mx = 0;

	loop(i,0,gr[node].size())
		mx = max(mx, dfs(gr[node][i]));

	len[node] = max(len[node], 1+mx);
	return len[node];
}
int main()
{
	fastio();

	int n,m;
	cin>>n>>m;

	loop(i,0,m)
	{
		int u,v;
		cin>>u>>v;
		gr[u].pb(v);
	}

	loop(i,1,n+1)
	{
		if(vis[i]==0)
			dfs(i);
	}

	int mx = 0;
	loop(i,1,n+1)
	{
	// 	cout<<len[i]<<" ";
		mx = max(mx, len[i]);
	}

	cout<<mx-1,nl;

	//cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a), i##ed = (b); i <= i##ed; i++)
#define per(i, a, b) for(int i = (a), i##ed = (b); i >= i##ed; i--)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 998244353;
const int N = 1000010;
ll S;
ll ax, ay, bx, by;

template<typename T> void gi(T &x) {
	x = 0; register char c = getchar(), pre = 0;
	for(; c < '0' || c > '9'; pre = c, c = getchar());
	for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10ll + (c ^ 48);
	if(pre == '-') x = -x;
}
inline int add(const int &x, const int &y) {
	return x + y < mod ? x + y : x + y - mod;
}
inline int sub(const int &x, const int &y) {
	return x - y < 0 ? x - y + mod : x - y;
}
inline int mul(const int &x, const int &y) { return (int)((ll)x * y % mod); }
int ksm(int x, int y = mod - 2) {
	int ss = 1; for(; y; y >>= 1, x = mul(x, x)) if(y & 1) ss = mul(ss, x);
	return ss;
}
int main() {
	scanf("%lld", &S);
	ll l = 1, r = 1000000000, mid;
	for(; l < r;) {
		mid = (l + r) / 2;
		if(mid * mid >= S) r = mid;
		else l = mid + 1;
	}
	ax = by = r, S = r * r - S;
	if(S <= 1000000000) ay = 1, bx = S;
	else {
		for(ll i = 2; i * i <= S; i++) {
			if(S % i == 0) {
				ay = i, bx = S / i; break;
			}
		}
	}
	printf("%d %d %d %d %d %d\n", 0, 0, ax, ay, bx, by);
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var K = input.split(' ')[0] - 0;
    var X = input.split(' ')[1] - 0;

    if (K === 1) {
        console.log(X);
        return;
    }

    var a = K - 1;

    for (var i = 0; i < 2 * K - 1; i++){
        var tmp = X - Math.abs(a) + i;
        console.log(tmp);
    }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        k = n-(i+j) #1000円の枚数
        sum = 10000 * i + 5000 * j
        if k >= 0 and (sum + 1000*k) == y:
            print(i,j,k)
            quit()
print(-1,-1,-1)

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

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N - 1);

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  for (int i = 0; i < N - 1; i++) {
    cin >> C[i];
  }

  int answer = 0;
  int current = 100;

  for (int i = 0; i < N; i++) {
    answer += B[A[i] - 1];
    if (A[i] - current == 1){
      answer += C[A[i] - 2];
    }
    current = A[i];
  }

  cout << answer << endl;

}

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

#define ll long long
#define vi vector<int> 
#define pb push_back
#define sz(s) (int)a.size()	

int n, a, b;
 
int main(){
	cin >> n >> a >> b;
	if(abs(a - b) % 2 == 0){
		cout << "Alice";
	}
	else {
		cout << "Borys";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll MAXN = 1e5 + 10;
ll d[MAXN],level[MAXN];
const ll MOD = 998244353;

ll power(ll x,ll y){
    if(x == 0) return 0;
    ll res = 1;

    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y>>=1;
    }

    return res;
}

void solve(){
    ll n; cin>>n;

    FOR(i,1,n){
        cin>>d[i];
        level[d[i]]++;
    }

    bool flag = false;
    FOR(i,0,n-2){
        if(level[i] == 0 && level[i+1] != 0) flag = true;    
    }

    if(d[1] != 0) flag = true;
    if(level[0] != 1) flag = true;

    if(flag){
        cout<<0<<endl;
    }else {
        ll ans = 1;
        FOR(i,1,n-1){
            if(level[i] == 0) break;
            ans = (ans*power(level[i-1],level[i]))%MOD;
        }

        cout<<ans<<endl;
    }
}

signed main(){

   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <queue>

using namespace std;
const int NONE = -1;

struct Exchange
{
    long long index, cost;
    Exchange(long long n, long long c) : index(n), cost(c) {}
    bool operator>(const Exchange &s) const
    {
        return cost > s.cost;
    }
};

struct S
{
    long long node, cost, prev;
    S(long long n, long long c, long long p) : node(n), cost(c), prev(p) {}
    bool operator>(const S &s) const
    {
        return cost > s.cost;
    }
};

class G
{
    long long n;
    vector<map<long long, long long> > cost;

  public:
    vector<long long> minc;
    vector<long long> prev;

    G(long long n, vector<map<long long, long long> > cost) : n(n), cost(cost), minc(n, NONE), prev(n) {}

    void dijkstra(long long start)
    {
        minc.assign(n, NONE);
        priority_queue<S, vector<S>, greater<S> > pq;
        pq.push(S(start, 0, NONE));
        while (!pq.empty())
        {
            S s = pq.top();
            pq.pop();
            if (minc[s.node] != NONE)
            {
                continue;
            }
            minc[s.node] = s.cost;
            prev[s.node] = s.prev;
            for (auto itr = cost[s.node].begin(); itr != cost[s.node].end(); ++itr)
            {
                pq.push(S(itr->first, s.cost + itr->second, s.node));
            }
        }
    }

    void input();
    void output()
    {
        for (int i = 0; i < n; i++)
        {
            cout << i << ":" << minc[i] << endl;
        }
    };
};

int main()
{
    // 整数の入力
    long long n, m, s, t, i, ui, vi, ai, bi, StartYen;
    StartYen = 1e15;
    vector<map<long long, long long>> G_yen;
    vector<map<long long, long long>> G_snuke;

    cin >> n >> m >> s >> t;
    for (i = 0; i < n; i++)
    {
        map<long long, long long> yen_edges;
        map<long long, long long> snuke_edges;
        G_yen.push_back(yen_edges);
        G_snuke.push_back(snuke_edges);
    }

    for (i = 0; i < m; i++)
    {
        cin >> ui >> vi >> ai >> bi;
        G_yen[ui - 1][vi - 1] = ai;
        G_yen[vi - 1][ui - 1] = ai;
        G_snuke[vi - 1][ui - 1] = bi;
        G_snuke[ui - 1][vi - 1] = bi;
    }

    G yenMap(n, G_yen);
    G snukeMap(n, G_snuke);

    yenMap.dijkstra(s - 1);
    snukeMap.dijkstra(t - 1);
    // yenMap.output();
    // snukeMap.output();

    priority_queue<Exchange, vector<Exchange>, greater<Exchange>> total_costs;

    for (i = 0; i < n; i++)
    {
        // cout << i << ":" << yenMap.minc[i] + snukeMap.minc[i] << endl;
        total_costs.push(Exchange(i, yenMap.minc[i] + snukeMap.minc[i]));
    }

    for (i = 0; i < n; i++)
    {
        bool outputted = false;
        while (!outputted)
        {
            Exchange e = total_costs.top();
            if (e.index >= i)
            {
                outputted = true;
                cout << StartYen - e.cost << endl;
            }
            else
            {
                total_costs.pop();
            }
        }
    }

    return 0;
}

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

int a[26], sum = 0, n;

int main()
{
    //freopen("demo.in", "r", stdin);
    //freopen("demo.out", "w", stdout);

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", a + i);
    }
    for (int i = 1; i < n - 1; i++)
    {
        if ((a[i] - a[i-1]) * (a[i] - a[i+1]) < 0)
        {
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    String y = sc.next();
    String ans[] = {"<", "=", ">"};
    if (x.compareTo(y)<0){
      System.out.println("<");
    }else if (x.compareTo(y)==0){
      System.out.println("=");
    }else{
      System.out.println(">");
    }
  }
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;
int a[105],x,num,y;
int main()
{

  cin>>n>>k;
  for(int i=1;i<=k;i++)
  {
  	  cin>>x;
  	  for(int j=1;j<=x;j++) cin>>y,a[y]++;
  }
  for(int i=1;i<=n;i++) 
    if(a[i]==0) num++;
  cout<<num;
return 0;
}


Measured memory_bytes: 3592
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p, q = 0, 0
for i in range(N):
    p += (P[i] - 1) * math.factorial(N-1-i)
    q += (Q[i] - 1) * math.factorial(N-1-i)
    for j in range(i+1, N):
        if P[j] > P[i]:
            P[j] -= 1
        if Q[j] > Q[i]:
            Q[j] -= 1

print(abs(p-q))


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int main(){
  char b;
  scanf("%c",&b);
  if(strcmp(&b,"A")==0) printf("T\n");
  if(strcmp(&b,"C")==0) printf("G\n");
  if(strcmp(&b,"G")==0) printf("C\n");
  if(strcmp(&b,"T")==0) printf("A\n");
  return 0;
}


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

using namespace std;

int H = 0, S[2000001];

void maxHeapify(int i) {
	int largest, l = 2 * i, r = 2 * i + 1;

	if (l <= H && S[l] > S[i]) largest = l;
	else largest = i;
	if (r <= H && S[r] > S[largest]) largest = r;

	if (largest != i) {
		int s = S[i]; S[i] = S[largest]; S[largest] = s;
		maxHeapify(largest);
	}
}

void Include() {
	H++; cin >> S[H];
	int i = H;
	while (i > 1 && S[i / 2] < S[i]) {
		int s = S[i]; S[i] = S[i / 2]; S[i / 2] = s; i /= 2;
	}
}

void extractMax() {
	cout << S[1] << endl;
	S[1] = S[H]; H--;
    maxHeapify(1);
}

int main() {
	string cmd;

	S[0] = -1;
	while (true) {
		cin >> cmd;
		if (cmd == "end") break;
		else if (cmd == "insert") {
			Include();
		}
		else if (cmd == "extract") {
			extractMax();
		}
	}

	return 0;
}


Measured memory_bytes: 6980
def main():
    a, b = map(int, input().split())

    coin = 0;
    if a == b:
        print(a * 2)
    elif a < b:
        coin += b + max(a, b-1)
        print(coin)
    else:
        coin += a + max(a-1, b)
        print(coin)


if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int a[N], pre[N], suff[N];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, maxgcd;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	pre[0] = a[0];
	suff[n-1] = a[n-1];
	for(int i = 1; i < n; i++) pre[i] = __gcd(a[i],pre[i-1]);
	for(int i = n-2; i >= 0; i--) suff[i] = __gcd(a[i],suff[i+1]);

	maxgcd = suff[1];
	for(int i = 1; i < n; i++){
		if(__gcd(pre[i-1], suff[i+1]) > maxgcd) maxgcd = __gcd(pre[i-1], suff[i+1]);
	}
	cout << maxgcd ;
}	

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

int main(){
    string S;
    cin >> S;
    int N = S.length();
    S += "Z";
    long long A = 0;
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'A')A++;
        else if(S.substr(i, 2) == "BC"){
            ans += A;
            i++;
        }
        else A = 0;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main( void )
{
  string S;
  cin >> S;

  string num;
  num =  to_string(S.size() - 2);
  
  string T = S.at( 0 ) + num + S.at( S.size() - 1 );

  cout << T << endl;
}
  

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

using namespace std;

int cnt, n, tr, a, b;

int main() {
	cin >> n;
	cnt = 0;
	tr = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a == b) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		if (cnt == 3) tr = 1;
	}
	if (tr == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mi map<int,int>
#define mii map<pii,int>
const int N=(1e5+1);//mod=(1e9)+7;
int n,k,d;//
int a[N],dp[N];
string s;
int flag=1;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        int x=abs(a[i+1]-a[i])+dp[i+1];
        int y=INT_MAX;
        if(i+2<n)
        {
            y=abs(a[i+2]-a[i])+dp[i+2];
        }
        dp[i]=min(x,y);
    }
    cout<<dp[0]<<endl;
}
/*
test cases:-
100000000000000012 1000000000032
*/

Measured memory_bytes: 1024
#include<stdio.h>
#define M 50
int main(){
  int hoge=0,fuga=0,ans=0;
  int n,m;
  int i,j;
  int a[M],b[M],c[M]={};
  scanf("%d %d", &n,&m);
  for(i=0;i<m;i++)
    scanf("%d %d", &a[i],&b[i]);
  int count=1;
  while(count!=0){
    count=0;
    for(i=0;i<m;i++){
      if(c[i]==0){
        for(j=0;j<m;j++){
          if((i!=j)&&(c[j]==0)){
            if(a[i]==a[j]||a[i]==b[j])hoge++;
            if(b[i]==a[j]||b[i]==b[j])fuga++;
          }
        }
        if(hoge==0||fuga==0){
          ans++;
          c[i]=1;
          count++;
        }
        hoge=0;fuga=0;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

struct UnionFind{//雛形を与える(初期化と結合のみ)
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    void init(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

    int root(int x){//木の根を求める
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};
typedef pair<int, int> P;

int main(){
    long long N, K, L;
    std::cin >> N >> K >> L;
    UnionFind U, U2, U3;
    U.init(N);
    U2.init(N);
    U3.init(N);
    std::vector<int> a(K), b(K), c(L), d(L);
    for(int i = 0; i < K; i++){
        std::cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        U.unite(a[i], b[i]);
    }
    for(int i = 0; i < L; i++){
        std::cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
        U2.unite(c[i], d[i]);
    }
    map<P, int> m;
    for(int i = 0; i < N; i++){
        P p = P(U.root(i), U2.root(i));
        m[p]++;
    }
    for(int i = 0; i < N; i++){
        P p = P(U.root(i), U2.root(i));
        cout << m[p];
        if(i == N - 1) cout << endl;
        else cout << ' ';
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> light(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            light[i].push_back(--s);
        }
    }
    vector<int> p(m);
    rep(i, m) {
        cin >> p[i];
    }
    // int c = pow(2,n);
    int ans = 1 << n;
    rep(i, 1 << n) {
        bitset<10> bit = i;
        rep(j, m) {
            int cnt = 0;
            rep(k, light[j].size()) {
                if (bit.test(light[j][k])) cnt++;
            }
            if (cnt % 2 != p[j]) {
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    long long ans = 0;
    int n = s.size();
    for(int i = 0;i < n;i++){
        ans += (s[i] - '0');
    
    }
    if(ans % 9 == 0)cout << "Yes"; else cout << "No";
    return 0;
}

Measured memory_bytes: 3768
def calc(arr, n)
  (1...n).each{|i| arr[i] += arr[i-1] }
  arr.each{ |v| $list[v] += 1 }
end
def calc2(arr, n)
  (1...n).each{|i| arr[i] += arr[i-1] }
  arr.each{ |v| $res += $list[v] }
end
loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0
  l = n.times.map{ gets.to_i }
  k = m.times.map{ gets.to_i }
  $list = [0] * ([l.reduce(:+), k.reduce(:+)].max + 1)
  $res = 0
  (0...n).each{ |i| calc(l[i..-1], n - i) }
  (0...m).each{ |i| calc2(k[i..-1], m - i) }
  p $res
end

Measured memory_bytes: 38168
#include <stdio.h>

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

  scanf("%d%d%d%d", &A, &B, &C, &D);

  if(B < C){
    printf("%d\n", 0);
  }else if(A < C){
    if(B < D){
      printf("%d\n", B - C);
    }else{
      printf("%d\n", D - C);
    }
  }else{
    if(B < D){
      printf("%d\n", B - A);
    }else if(A < D){
      printf("%d\n", D - A);
    }else{
      printf("%d\n", 0);
    }
  }
  
  return 0;
}


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

int n, a;
int x[51];
long long dp[51][2501];


int main()
{
	long long sum(0ll), ans(0ll);
	
	scanf("%d%d", &n, &a);
	for (int i = 1; i <= n; ++i)
		scanf("%d", x + i);
	dp[0][0] = 1ll;
	for (int i = 1; i <= n; ++i) {
		sum += x[i];
		for (int j = i; j; --j)
			for (int k = sum; k >= x[i]; --k)
				dp[j][k] += dp[j - 1][k - x[i]];
	}
	for (int i = 1; i <= n; ++i)
		ans += dp[i][a * i];
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 1280
n,d = gets.split.map(&:to_i)
z = []
n.times do
  a = gets.split.map(&:to_i)
  z << a
end
count = 0
z.combination(2).to_a.each do |a,b|
  sum = 0
  d.times do |i|
    sum += (a[i] - b[i])**2
  end
  count += 1 if Math.sqrt(sum).to_s.split('.')[-1].to_i.zero?
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<bool> v(100);
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		v.at(d - 1) = 1;
	}

	cout << count(v.begin(), v.end(), 1) << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		long ans = 0;
		for(int i = 0; i < n; i++) {
			ans += a[i]/2;
			a[i] %= 2;
			if(i != (n-1) && a[i] > 0 && a[i+1] > 0) {
				ans++;
				a[i]--;
				a[i+1]--;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 59580
#include<iostream>
using namespace std;
int a[110]={0};
int main()
{
	int A,B,C,D,sum=0;
	cin>>A>>B>>C>>D;
		for(int i=0;i<=110;i++)
		{
			if(i>=A&&i<B)
			a[i]++;
			if(i>=C&&i<D)
			a[i]++;
		}
		for(int i=0;i<=110;i++)
		{
			if(a[i]==2)
			sum++;
		}
		cout<<sum<<endl;

}

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

    typedef long long ll;
    typedef long double ld;
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
    #define endl '\n'
    #define max3(a,b,c) max(a,max(b,c))
    #define FOR(i,a,n,j) for(int i=a;i<n;i+=j)

    const int INF = 1e9+9;




    int main()
    {
        int n;
        cin>>n;
        int dp[n+5];
        vector<int> v(n);
        FOR(i,0,n,1){
            cin>>v[i];
            dp[i] = INF;
        }
        v.push_back(INF);
        v.push_back(INF);
        v.push_back(INF);
        dp[0] = 0;
        FOR(i,0,n,1){
            dp[i+1]= min(dp[i+1], dp[i]+abs(v[i]-v[i+1]));
            dp[i+2]= min(dp[i+2], dp[i]+abs(v[i]-v[i+2]));
        }

        cout<< dp[n-1] <<endl;

        return 0;
    }
        // gotcha;


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

const int MAX_N=100009;
int par[MAX_N];
int myrank[MAX_N];
//int size[MAX_N];

void init(int n){
  for(int i=1;i<=n;i++){par[i]=i; myrank[i]=0;}
}

int find(int x){
  if(par[x]==x){return x;}
  else{return par[x]=find(par[x]);}
}

void unite(int x, int y){
  x=find(x); y=find(y);
  if(x==y){return;}
  if(myrank[x]<myrank[y]){par[x]=y; }
  else{par[y]=x;}
  if(myrank[x]==myrank[y]){myrank[x]++;}
}

bool same(int x, int y){return find(x)==find(y);}
bool q[100009];

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> X(M),Y(M),Z(M);
  for(int i=0;i<M;i++){cin >> X[i] >> Y[i] >> Z[i]; Z[i]=Z[i]%2;}
  init(N);
  for(int i=0;i<M;i++){
    unite(X[i],Y[i]);
  }
  int cnt=0;
  for(int i=1;i<=N;i++){
    if(!q[find(i)]){cnt++; q[find(i)]=true;}
  }
  cout << cnt << endl;
}

Measured memory_bytes: 2304
n = int(input())
s=''
k=1
while n>0:
    if n-26**k>0:
        n-=26**k
        k+=1
    else:
        p='abcdefghijklmnopqrstuvwxyz'
        #print(len(p))
        j=0
        while n>0:
            if n-26**(k-1)>0:
                n-=26**(k-1)
                j+=1
            else:
                s+=p[j]
                #print(s,n,k,j)
                if n==1 and k==1:
                    n=0
                j=0
                k-=1
                
                
print(s)
                
            
    

Measured memory_bytes: 9168
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[] alphabet = new int[26];
        int check;
        while(str != null) {
            str = str.toLowerCase();
            for (int i = 0; i < str.length(); i++) {
                check = Character.getNumericValue(str.charAt(i));
                if (check - 10 >= 0 && check - 10 <= 25) {
                    alphabet[check - 10] += 1;
                }
            }
            str = input.readLine();
        }
        char[] ch;
        String str2;
        for (int i = 0; i < 26; i++) {
            ch = Character.toChars(i + 0x61);
            str2 = new String(ch);
            System.out.println(str2 + " : " + alphabet[i]);
        }
    }
 
}

Measured memory_bytes: 24264
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;
 
using namespace std;
 
ll aMax[100005];
ll aMin[100005];
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> a(3*N);
  REP(i,3*N){
    cin >> a[i];
  }
  priority_queue<ll, vector<ll>, greater<ll>> maxque;
  priority_queue<ll> minque;
  REP(i,N){
    maxque.push(a[i]);
    minque.push(a[i+2*N]);
    aMax[0] += a[i];
    aMin[0] += a[i+2*N];
  }
  REP(i,N){
    maxque.push(a[N+i]);
   ll mi = maxque.top();
    maxque.pop();
    aMax[i + 1] = aMax[i] - mi + a[N+i];
  }
  REP(i,N){
    minque.push(a[2*N-i-1]);
  ll ma = minque.top();
    minque.pop();
    aMin[i + 1] = aMin[i] - ma + a[2*N-i-1];
  }
  ll ans = -1e16;
  REP(i,N + 1){
    ans = max(ans, aMax[i] - aMin[N - i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5996
hist = []
nm = list(map(int, input().split()))
for i in range(nm[1]):
    a,b=input().split()
    hist.append((int(a), b))

ac = [0] * nm[0]
wa = [0] * nm[0]

for i in range(nm[1]):
    if hist[i][1] == "AC":
        if ac[hist[i][0]-1] != 1:
            ac[hist[i][0]-1] = 1
    elif hist[i][1] == "WA":
        if ac[hist[i][0]-1] != 1:
            wa[hist[i][0]-1] = wa[hist[i][0]-1] + 1


for i in range(nm[0]):
    wa[i] = wa[i] * ac[i]

print(sum(ac), sum(wa))

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

int main()
{
	std::string s;
	std::cin >> s;
	char pre{s.front()};
	int count{};
	for (unsigned int i{1}; i < s.size(); i++)
	{
		if (s[i] == pre) continue;
		count++;
		pre = s[i];
	}
	printf("%d\n", count);

	return 0;
}

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

const int maxn=1000007;
int A,B,C;
int a[maxn],b[maxn];
int main(){
    cin>>A>>B>>C;
    int mn=1e9,ret=0;
    for (int i=1;i<=A;++i){
        cin>>a[i];
        mn=min(mn,a[i]);
    }
    ret+=mn;
    mn=1e9;
    for (int i=1;i<=B;++i){
        cin>>b[i];
        mn=min(mn,b[i]);
    }
    ret+=mn;
    for (int i=1;i<=C;++i){
        int u,v,w;
        cin>>u>>v>>w;
        ret=min(ret,a[u]+b[v]-w);
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 4736
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] t = in.nextLongArray(n), a = in.nextLongArray(n);

			long[] tCalc = new long[n];
			Arrays.fill(tCalc, -1);

			long[] aCalc = new long[n];
			Arrays.fill(aCalc, -1);

			long[] tDef = new long[n];
			long[] aDef = new long[n];

			long tMax = -1, aMax = -1;
			for (int i = 0; i < n; i++) {
				if (tMax < t[i]) {
					tMax = t[i];
					tDef[i] = t[i];
				} else {
					tCalc[i] = tMax;
				}
			}
			for (int i = n-1; i >= 0; i--) {
				if (aMax < a[i]) {
					aMax = a[i];
					aDef[i] = a[i];
				} else {
					aCalc[i] = aMax;
				}
			}

			for (int i = 0; i < n; i++) {
				if (aCalc[i] == -1 && tCalc[i] == -1) {
					if (aDef[i] != tDef[i]) {
						out.println(0);
						return;
					}
				} else if (aCalc[i] == -1) {
					if (aDef[i] > tCalc[i]) {
						out.println(0);
						return;
					}
				} else if (tCalc[i] == -1) {
					if (tDef[i] > aCalc[i]) {
						out.println(0);
						return;
					}
				}
			}

			long ans = 1;
			for (int i = 0; i < n; i++) {
				if (tCalc[i] == -1 || aCalc[i] == -1) {
					continue;
				}
				ans = ans * min(aCalc[i],tCalc[i]) % modP;
			}
			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 49824
#include <vector>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int n,m,ans=1;
    cin >> n >> m;
    if(n==m){
        for(int i=1;i<=n;i++){
            ans*=i;
            ans%=1000000007;
        }
        for(int j=1;j<=m;j++){
            ans*=j;
            ans%=1000000007;
        }
        ans*=2;
        ans%=1000000007;
        cout << ans;
    }else if(abs(n-m)==1){
        for(int i=1;i<=n;i++){
            ans*=i;
            ans%=1000000007;
        }
        for(int j=1;j<=m;j++){
            ans*=j;
            ans%=1000000007;
        }
        cout << ans;
    }else{
        cout << 0;
    }
}


Measured memory_bytes: 256
// 2018/01/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int h, w;
		cin >> h >> w;

		if(h==0 && w==0)
			break;

		int d = h*h+w*w;			// 元の長方形の対角線の二乗

		int H = 150;
		int W = 150;
		int D = 150*150+150*150;		// 求める長方形の対角線の二乗

		for(int y=1; y<=150; y++){		// 対角線の長さが元より長い場合
			for(int x=y+1; x<=150; x++){
				int z = y*y+x*x;

				if(z<=d){
					continue;
				}
				else{
					if(z<D){
						H = y;
						W = x;
						D = z;
					}
					break;
				}
			}
		}

		for(int y=h+1; y<150; y++){		// 対角線の長さが元と同じ場合
			bool flg = false;

			for(int x=y+1; x<=150; x++){
				int z = y*y+x*x;

				if(z==d){				// 見つかったら
					H = y;
					W = x;
					D = z;

					flg = true;
				}

				if(z>=d)
					break;
			}

			if(flg)					// 見つかったら
				break;
		}

		cout << H << ' ' << W << endl;
	}

	return 0;
}



Measured memory_bytes: 3104
package main

import "fmt"

const INF = 114514810

func main() {
	var cost [10][10]int
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if i != j {
				cost[i][j] = INF
			}
		}
	}

	var h, w int
	fmt.Scan(&h, &w)
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			var c int
			fmt.Scan(&c)
			cost[i][j] = c
		}
	}

	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				t := cost[i][k] + cost[k][j]
				if t < cost[i][j] {
					cost[i][j] = t
				}
			}
		}
	}

	res := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			var a int
			fmt.Scan(&a)
			if a == -1 {
				continue
			}
			res += cost[a][1]
		}
	}

	fmt.Println(res)
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   int n;
   int count = 0;
   cin >> n;
   vector<int> d(n);
   rep(i,0,n) cin >> d[i];
   rep(i,0,n){
       rep(j,i+1,n){
           count+=d[i]*d[j];
       }
   }

   cout << count << endl;
   return 0;
}


Measured memory_bytes: 256
#!/bin/bash

awk -M '\
NR==1{N=$1}
NR==2{split($0,A)}
END{
    asort(A);
    if(!A[1]){
        print 0;
        exit
    }
    s=1
    for(i=N;i>=1;i--){
        s*=A[i];
        if(s>1e18){
            print -1;
            exit;
        }
    }
    print s
}'


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, std::vector<long long> A, std::vector<long long> B){

    lli cnt=0;
    for(lli i=N-1;i>=0;i--){
        if(B[i]>=A[i+1]){
            B[i]-=A[i+1];
            cnt += A[i+1];
        }
        else{
            cnt += B[i];
            B[i]=0;
        }

        lli tmp = min(B[i],A[i]);
        cnt += tmp;
        B[i]-=tmp;
        A[i]-=tmp;
    }

    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 0 ; i < N+1 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    func(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean res = false;
        for(int i = 1; i < 10; i++) {
            if(N % i == 0 && N / i < 10) {
                res = true;
                break;
            }
        }
        if(res) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35668