jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
import Foundation
// 第一引数には約数を列挙したい自然数を渡す
func print_divisors(n:Int)->[Int]{
    // 戻り値となる配列の初期化
    var divisors:[Int] = []
    // ループを回すのは√nまでで十分
    for i in 1...Int(sqrt(Double(n))){
        // 割り切れるならiはnの約数
        if n % i == 0{
            divisors.append(i)
            // i != n / i なら i^2 != n
            if i != n / i{
                divisors.append(n/i)
            }
        }
    }
    // 配列をソートする
    divisors.sort{ $0 < $1 }
    // divisorsを返す
    return divisors
}

// 標準入力の受け取り
let n = Int(readLine()!)!

// 約数列挙
let check = print_divisors(n:n)

// 答えとなる変数ansの初期化 (とりあえずめっちゃでかい値入れておく)
var ans = 100000000000000

// 各約数についてループを回す
for i in check{
    
    // ループは √n までで十分
    if i > Int(sqrt(Double(n))){
        break
    }
    
    // より小さい値をansに代入
    ans = min(ans,i+n/i-2)
}

// 答えを返す
print(ans)
//  [swift]
// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}
// https://melheaven.hatenadiary.jp/entry/atcoder144
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

func main() {
    let n = readInt()
    let ary = makeDivisors(n)
    print(ary.min()! - 2)
}
main()
//  [swift]
// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}


func main() {
    let n = readInt()
    
    if (isPrime(n)) && Int(sqrt(Double(n))) == n {
        print(n - 1)
        return
    }
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > a + b - 2  {
        ans = a + b - 2
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }
    
    print(a + b - 2)
}
main()
//  [swift]
// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}


func main() {
    let n = readInt()
    
    if (isPrime(n)) && Int(sqrt(Double(n))) == n {
        print(n - 1)
        return
    }
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > a + b - 2  {
        print(ans,a,b)
        ans = a + b - 2
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }
    
    print(a + b - 2)
}
main()
//  [swift]
// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}


func main() {
    let n = readInt()
    
    if (isPrime(n)) {
        print(n - 1)
        return
    }
    var a = Int(sqrt(Double(n)))
    var b = a
    var ans = n - 1
    while ans > (a - 1) + (b - 1) {
        ans = (a - 1) + (b - 1)
        while n % a != 0 {
            a += 1
        }
        b = n / a
    }
    
    print((a - 1) + (b - 1))
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};const deduplicate=(a:number[])=>{return Array.from(new Set(a))};const permutation=(arr,n)=>{var arrs,i,j,zensu,results,parts;arrs=[];zensu=arr.length;if(zensu<n){return}else if(n==1){for(i=0;i<zensu;i++){arrs[i]=[arr[i]]}}else{for(i=0;i<zensu;i++){parts=arr.slice(0);parts.splice(i,1)[0];results=permutation(parts,n-1);for(j=0;j<results.length;j++){arrs.push([arr[i]].concat(results[j]))}}}return arrs}
const main=()=>{
  let n=tn(),ans=n;
  let y=n,xx=1,yy=n
  for(let x=1;x<=y;x++){
    y=n/x
    if(Number.isInteger(y)){
      xx=x
      yy=y
    }
  }
  to(xx+yy-2)
}
main()
//  [typescript]
function main(input: string[]): void {
    const n = parseInt(input.shift());
    let min = n * 2;
    let log = Math.ceil(Math.sqrt(n));
    for (let i = 1; i <= log; i++) {
        if (n % i === 0) {
            min = Math.min(min, i + Math.round(n / i));
            //puts(i, i + n / i, min);
        }
    }
    puts(min - 2);
}

// === BEGIN MODULE ===
function puts(...message: any[]): void {
    console.log(message.join(' '));
}
// === END   MODULE ===

import { readFileSync } from 'fs';
if (process.argv[1] == __filename) {
    const path = process.argv[2] || '/dev/stdin';
    const input = readFileSync(path, 'utf-8');
    main(input.split(/\s+/));
}
//  [typescript]
function main(p){
  const num = parseInt(p.split('\n')[0], 10)
  let ans
  for (let i=1; i<=Math.sqrt(num); i++){
    if(num % i === 0){
      ans = num/i + i - 2
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const { pairs } = _divisor(N)

    let res = Infinity

    pairs.forEach(([a, b]) => {
      const k = a + b - 2

      res = Math.min(res, k)
    })
    console.log(res)
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }
  const _divisor = (n: number) => {
    const sq = Math.floor(Math.sqrt(n))
    const list: number[] = []
    const pairs: [number, number][] = []

    if (n % sq === 0) {
      list.push(sq)
      pairs.push([sq, sq])
    }
    for (let i = sq - 1; i > 0; i--) {
      if (n % i === 0) {
        list.unshift(i)
        list.push(n / i)
        pairs.unshift([i, n / i])
      }
    }
    return { list, pairs }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}
//  [typescript]
const main = (input) => {
  const n = Number(input)
  let result = n-1
  for (let i = 1; i*i < n; i++) {
    if (n%i === 0) {
    　const num = i + n/i - 2
      result = num < result ? num : result
    }
  }
  console.log(result)

  
  
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
'use strict'
function main(input: string) {
    const n: number = Number(input.split('\n')[0]);
    let s: string[] = [];
    for (let i = 1; i <= n; i++) {
        s.push(input.split('\n')[i].split('').sort().join(''));
    }
    let r = 0;
    let tmp = {};
    s.forEach(v => {
        if (v in tmp) {
            r += tmp[v];
            tmp[v]++;
        } else {
            tmp[v] = 1;
        }
    });
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
N = int(input())
if N%2 == 0:
    print(N)
else:
    print(2*N)
//  [python]
N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N * 2)
//  [python]

N = input()

i = N + 1
while True:
    if(i % 2 == 0 and i % N == 0):
        break
    i = i + 1

print(i)
//  [python]
import math
N=int(input())
print(2*N//gcd(2,N))
//  [python]
print(int(input())*2)
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(problem102a(n));
    }

    private static int problem102a(int n) {
        return (n % 2 == 0) ? n : (n * 2);
    }
}
//  [java]
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println(N % 2 == 0 ? N : 2 * N);
        }
    }
}
//  [java]
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        if (n % 2 == 0) System.out.println(n);
        else System.out.println(n*2);
    }
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] numbers = new int[N];
		
		for(int j = 0; j <numbers.length; j++) {
			numbers[j] = sc.nextInt();
		}
		
		int max = numbers[0];
		int min = numbers[0];
		
		for(int i = 1; i < numbers.length; i++ ) {
			if(numbers[i] > max ) {
				max = numbers[i];
			}
			if(numbers[i] < min ) {
				min = numbers[i];
			}
		}
		System.out.println(max-min);
	}

}
//  [java]


import java.util.*;
import java.io.*;

public class Main {
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

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

	static final FS sc = new FS();
	static final PrintWriter out = new PrintWriter(System.out);
	static final int mod = 1000000007;

	public static void main(String[] args) {
		solve();
		out.close();
	}

	static void solve() {
		long n = sc.nextInt();
		long i = n;
		while(true) {
			if(i % n == 0 && i % 2 == 0) {
				out.println(i);
				break;
			}
			else i++;
		}
			
		

	}

	}
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 2; i <= Integer.MAX_VALUE; i+=2) {
            if (i%2==0 && i%n==0) {
                System.out.println(i);
                return;
            }
        }
    }
}
//  [cpp]
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
ll K;

int main()
{
	scanf("%d",&n);
	if(n%2==1)n *= 2;
	printf("%d\n",n);
	return 0;
}
//  [cpp]
#include<stdio.h>

int main()
{
	int N;
	scanf("%d",&N);
	
	if(N%2==0)
		printf("%d\n",N);
	else
		printf("%d\n",N*2);
	
	return 0;
}
//  [cpp]
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int x;
	int answer = 1;
	scanf("%d", &x);

		if (x % 2 == 0)
		{
			answer = x;
			goto exit;
		}
		else
		{
			answer = 2 * x;
		}
exit:
	printf("%d", answer);


	return 0;
}
//  [cpp]
/******************************************
* AUTHOR : ARPIT *
* NICK : arpitfalcon *
* INSTITUTION : BIT MESRA *
* Ab m game m hu. *
******************************************/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 -
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vin                    \
    ll n;                      \
    cin >> n;                  \
    vector<ll> x(n);           \
    for (ll i = 0; i < n; i++) \
    cin >> x[i]
#define vout                   \
    for (ll i = 0; i < n; i++) \
    cout << x[i] << " "
#define T     \
    ll t = 1; \
    cin >> t; \
    while (t--)
#define ain                    \
    ll n, k;                   \
    cin >> n >> k;             \
    ll a[n];                   \
    for (ll z = 0; z < n; z++) \
    cin >> a[z]
#define aout                   \
    for (ll i = 0; i < n; i++) \
    cout << a[i] << " "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define max4(a, b, c, d) max(a, max3(b, c, d))
#define min4(a, b, c, d) min(a, min3(b, c, d))
#define blink                \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI = 3.141592653589793238463;

#define forn(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define for1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define forr(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))

/*
__builtin_ffs(x)
  Number of set bits: __builtin_popcount(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
*/

int main()
{
    blink
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    // your code goes here
    int n;
    cin >> n;
    if (n % 2)
    {
        cout << n;
    }
    else
    {
        cout << n * 2;
    }

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

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

	if (N % N == 0) {
		cout << N;
	}
	else
	cout << N * 2 << endl;
}
//  [cpp]
#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

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

	cout << N * 2 << endl;
}
//  [c]
#include <stdio.h>

int main()
{
  int N;
  scanf("%d",&N);
  if(N % 2 == 0){
      printf("%d",N);
  }else{
      printf("%d",2*N);
  }
    return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>
#include <string.h>
int main (void){
        long long int N;
          scanf("%lld",&N);
          if (N%2==1) {
            N*=2;
          }

        printf("%lld\n",N);

        return 0;

}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n%2==0)
        printf("%d\n",n);
    else
        printf("%d\n",2*n);

    return 0;
}
//  [c]
#include<iostream>
 
using namespace std;
 
int main(){
    long long n;
    cin >> n;
    if(n%2==1)printf("%lld\n", n*2);
    else printf("%lld\n", n);
    return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n)+
    if(n%2==0){
      printf("%d\n",n);
    }else{
      printf("%d\n",2*n);
    }
  return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int a;
    scanf("%4d",&a);
    if (a%2==0) printf("%d",a);
    else printf("%d",a*2);

    return 0;
}
//  [javascript]
// inputに入力データ全体が入る
function Main(str) {
  const num = Number(str);

  if (num <= 2) {
    console.log(2);
    return;
  }

  if (num % 2 === 0) {
    console.log(num);
    return;
  }

  console.log(num * 2);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  const N = parseInt(input.split(" ")[0], 10);
  if(N%2==0){
    console.log(N);
  }else{
    console.log(2*N);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

function main(input){
    const N = Number(input[0]);
    console.log((N%2+1)*N);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))
//  [javascript]
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])
  for (let i = 2; ; i += 2) {
    if (i % N === 0) {
      console.log(i)
      break
    }
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	if(N % 2 == 1){
		N++;
	}
	myout(N);
}
//  [javascript]
'use strict'
function Main(input) {
	const A = input.split('\n')[1].split(' ').map(Number);
  	console.log(Math.max(...A) - Math.min(...A));
}
Main(require('fs').readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
    . "fmt"
)

func main() {
    var n int
    Scanf("%d", &n)

    if n % 2 == 0 {
        Println(n)
    } else {
        Println(n * 2)
    }
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n%2 == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(n * 2)
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {

	var N int

	fmt.Scan(&N)

	fmt.Print(N * 2)

}
//  [go]
package main

import (
	"fmt"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func main() {
	var n int64
	fmt.Scan(&n)

	var ans int64 = min(2, n)
	for {
		if ans%2 == 0 && ans%n == 0 {
			fmt.Println(ans)
			return
		}
		ans += min(2, n)
	}
}
//  [go]
package main

import (
	"fmt"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func main() {
	var n int64
	fmt.Scan(&n)

	var ans int64 = min(2, n)
	for {
		if ans%2 == 0 && ans%n == 0 {
			fmt.Println(ans)
			return
		}
		ans += max(2, n)
	}
}
//  [ruby]
p 2.lcm(gets.to_i)
//  [ruby]
N = gets.to_i

if N % 2 == 0
  puts N
else
  puts 2 * N
end
//  [ruby]
n = gets.strip.to_i
puts (n % 2 != 0) ? 2 * n : n
//  [ruby]
n = gets.to_i
puts n.lcd(2)
//  [ruby]
n=gets.chomp
if n%2==0
  p n
else
  p n*2
end
//  [ruby]
n = gets.to_i

print n % 2 == 0 ? n : n+1
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let n = v[0];
	if n%2 == 0 {
		println!("{}", n);
	}else{
		println!("{}", 2*n);
	}
}
//  [rust]
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    println!("{}", n * ((n % 2) + 1));
}
//  [rust]
fn main() {
    let n = read::<usize>();
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}
//  [rust]
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  print $ if n `mod` 2 == 0 then n else 2 * n
//  [rust]
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"3"# => "6",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }

    let mut ans:usize = 0;
    let mut i:usize = 2;

    while ans == 0 {
        if i % n == 0 && i % 2 == 0 {
            ans += i;
            break;
        }
        i += 2;
    }
    ans.to_string()
}
//  [rust]
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"999999999"# => "1999999998",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: u64,
    }

    let mut ans:u64 = 0;
    let mut i:u64 = 2;

    while i <= 1_000_000_000 {
        if i % n == 0 && i % 2 == 0 {
            ans += i;
            break;
        }
        i *= 2;
    }
    ans.to_string()
}
//  [swift]
//let i=Int(readLine()!)!%2;print(i%2>0 ?i*2:i)
let N = Int(readLine()!)!
var ans = 0
if N % 2 == 0 {
	ans = N
} else {
	ans = N * 2
}
print(ans)
//  [swift]
let N=Int(readLine()!)!;print(N%2>0 ?N*2:N)
//  [swift]
let N=Int(readLine()!)!
if (N%2==0){
  print(N)
}else{
  print(2*N)
}
//  [swift]
let s = Int(readLine()!)!
let t = readLine()!.split(separator: " ").map({Int($0)!})
let max = t.max()!
let min = t.min()!
print(max - min)
//  [swift]
var N=Int(readLine()!)!;N%2>0 ?N*=2:;print(N)
//  [swift]
var N=Int(readLine()!)!;N%2>0 ?N*=2:break;print(N)
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

console.log(n % 2 === 0 ? n : n * 2)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let n=nin()
  if(n%2==0)out(n)
  else out(n*2)
}
main();
//  [typescript]
const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const n = parseInt(input[0], 10);
  
  if(n%2===0){
    console.log(n);
  }else{
    console.log(2*n);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const n = paeseInt(input[0], 10);
  
  if(n%2===0){
    console.log(n);
  }else{
    console.log(2*n);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  input = input.trim();
  input = input.split(' ');
  const n = paeseInt(input[0], 10);
  
  if(N%2===0){
    console.log(n);
  }else{
    console.log(2*n);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

let i = 1
while(1){
  if(i % 2 === 0 && i % n === 0) break
  i++
}

console.log(i)
//  [python]
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, input().split())
a = [10 ** 10] + list(map(int, input().split()))
b = [10 ** 10] + list(map(int, input().split()))
ans = 10 ** 10
for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x] + b[y] - c)
ans = min(ans, min(a) + min(b))

print(ans)
//  [python]
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())

    abm = [int(x) for x in input().rstrip().split(" ")]
    a_list = [int(x) for x in input().rstrip().split(" ")]
    b_list = [int(x) for x in input().rstrip().split(" ")]

    # 最小値
    ans = min(a_list) + min(b_list)

    for i in range(abm[2]):
        xyc = [int(x) for x in input().rstrip().split(" ")]
        price = a_list[xyc[0] - 1] + b_list[xyc[1] - 1] - xyc[2]
        if price < ans:
            ans = price

    print(ans)

if __name__ == "__main__":
    resolve()
//  [python]
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    ans = min(a) + min(b)
    for i in range(M):
        xi = x[i]
        yi = y[i]
        ci = c[i]
        t = a[xi-1] + b[yi-1] - ci
        if ans >= t:
            ans = t
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()
//  [python]
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
price_list = []

for s in a:
  for t in b:
    price_list.append(s + t)


for i in range(M):
  x, y, c = map(int, input().split())
  price = a[x-1] + b[y-1] - c
  price_list.append(price)


min_price = price_list[0]

for n in price_list:
  if min_price >= n:
    min_price = n
  elif min_price < n:
    pass


print(min_price)
//  [python]
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = []
y = []
c = []
for _ in range(M):
    X,Y,Z = map(int,input().split())
    x.append(X)
    y.append(Y)
    c.append(Z)

mini = min(a) + min(b)
for i in range(M):

    rei = a[x[i]-1]
    den = b[y[i]-1]
    coop = c[i-1]

    if rei + den - coop < mini:
        mini = rei + den - coop

print(mini)
//  [python]
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = []
y = []
c = []
for _ in range(M):
    X,Y,Z = map(int,input().split())
    x.append(X)
    y.append(Y)
    c.append(Z)

mini = max(a) + max(b)
for i in range(M):
    if a[x[i]-1] + b[y[i]-1] - c[i-1] < mini:
        mini = a[x[i]-1] + b[y[i]-1] - c[i-1]

print(min(mini,min(a) + min(b)))
//  [java]
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

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

    private static void run() {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        Scanner sc = new Scanner(System.in);
        // input
        int a = Integer.parseInt(sc.next()); // 冷蔵庫種類
        int b = Integer.parseInt(sc.next()); // クーラー種類
        int m = Integer.parseInt(sc.next()); // 割引券枚数
        // 冷蔵庫価格リスト
        ArrayList<Integer> alist = new ArrayList<>(a);
        for (int i = 0; i < a; i++) {
            alist.add(Integer.parseInt(sc.next()));
        }
        // クーラー価格リスト
        ArrayList<Integer> blist = new ArrayList<>(b);
        for (int i = 0; i < b; i++) {
            blist.add(Integer.parseInt(sc.next()));
        }
        // 割引券HashMap(key:割引対象番号,value:割引額)
        HashMap<String, Integer> discount = new HashMap<>(m);
        for (int i = 0; i < m; i++) {
            String x = sc.next(); // 割引対象の番号：冷蔵庫
            String y = sc.next(); // 割引対象の番号：クーラー
            int value = Integer.parseInt(sc.next()); // 割引額
            String key = x + y; // 2種類の割引対象番号を文字列結合
            // 同一の割引対象番号が複数存在する場合、割引額が大きい方を残す
            if (discount.containsKey(key)) {
                discount.put(key, Math.max(discount.get(key), value));
            } else {
                discount.put(key, value);
            }
        }

        // 合計額HashMap(key:商品番号,value:合計額)
        HashMap<String, Integer> totalprice = new HashMap<>();
        for (int i = 0; i < a; i++) {
            int aprice = alist.get(i);
            for (int j = 0; j < b; j++) {
                int bprice = blist.get(i);
                String key = String.valueOf(i + 1) + String.valueOf(j + 1);
                int value = aprice + bprice;
                if (discount.containsKey(key)) {
                    value -= discount.get(key);
                }
                totalprice.put(key, value);
            }
        }

        int answer = 999999999;
        for (String s : totalprice.keySet()) {
            answer = Math.min(answer, totalprice.get(s));
        }

        out.println(answer);
        out.close();
        sc.close();
    }

}
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

// 22
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[A];
        int[] b = new int[B];
        for(int i = 0; i < A; i++)
            a[i] = sc.nextInt();
        for(int i = 0; i < B; i++)
            b[i] = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 0; i < M; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            list.add(a[ai] + b[bi] - sc.nextInt());
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Collections.sort(list);

        System.out.println(Math.min(a[0] + b[0], list.get(0)));
    }

}
//  [java]
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		Integer[] a = new Integer[A];
		Integer[] b = new Integer[B];
		Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
		Arrays.setAll(b, i -> Integer.parseInt(sc.next()));
		List<Integer> listA = new ArrayList<>(Arrays.asList(a));
		List<Integer> listB = new ArrayList<>(Arrays.asList(b));
		listA.sort(Comparator.naturalOrder());
		listB.sort(Comparator.naturalOrder());
		int min = listA.get(0) + listB.get(0);
		int waribiki = Integer.MAX_VALUE;
		for(int i=0; i<M; i++){
			int x = listA.get(Integer.parseInt(sc.next()) - 1);
			int y = listB.get(Integer.parseInt(sc.next()) - 1);
			int c = Integer.parseInt(sc.next());
			if(x + y - c < waribiki){
				waribiki = x + y - c;
			}
		}
		
		System.out.println(min < waribiki ? min : waribiki);
	}
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//絶対無理そう

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int A = getint(), B = getint(), M = getint();

	int a[100001], b[100001];
	int ma = 100000, mb = 100000;
	rep1(i, A) {
		a[i] = getint();
		chmin(ma, a[i]);
	}
	rep1(i, B) {
		b[i] = getint();
		chmin(mb, b[i]);
	}

	int kotae = ma + mb;

	rep(i, M) {
		int x = getint(), y = getint(), c = getint();
		chmin(kotae, a[x] + b[y] - c);
	}

	printf("%d", kotae);

	Would you please return 0;
}
//  [cpp]
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int n,m,K,ans,a[maxn],b[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
int main(){
	n=read(),m=read(),K=read();a[0]=b[0]=1e9;
	for (int i=1;i<=n;i++) a[0]=min(a[0],a[i]=read());
	for (int i=1;i<=m;i++) b[0]=min(b[0],b[i]=read());
	ans=a[0]+b[0];
	for (int i=1;i<=K;i++){
		int x=read(),y=read(),c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
	return 0;
}
//  [cpp]
#include<iostream>
using namespace std;
#define size 100001
int main()
{
  unsigned int A,B,M;
  unsigned int a[size],b[size],discounts[size];
  unsigned int i,refrigerator,microwave,discount,min_microwave = size,min_refrigerator = size;
  cin>>A>>B>>M;
  for(i=0;i<A;i++)
  {
  	cin>>a[i];
  	min_refrigerator = min(min_refrigerator,a[i]);
  }
  for(i=0;i<B;i++)
  {
  	cin>>b[i];
  	min_microwave = min(min_microwave,b[i]);
  }
  for(i=0;i<M;i++)
  {
    cin>>refrigerator >> microwave >> discount;
    discounts[i] = a[refrigerator-1] + b[microwave-1] - discount;
  }
  unsigned int min_discount = size;
  for(i=0;i<M;i++)
  {
  	min_discount = min(min_discount,discounts[i]);
  }
  cout<<min(min_discount,min_microwave+min_refrigerator);

}
//  [cpp]
#include<iostream>
using namespace std;
#define size 100001
int main()
{
  unsigned int A,B,M;
  unsigned int a[size],b[size],discounts[size];
  unsigned int i,refrigerator,microwave,discount,j;
  cin>>A>>B>>M;
  for(i=0;i<A;i++)
  {
  	cin>>a[i];
  }
  for(i=0;i<B;i++)
  {
  	cin>>b[i];
  }
  for(i=0;i<M;i++)
  {
    cin>>refrigerator >> microwave >> discount;
    discounts[i] = a[refrigerator-1] + b[microwave-1] - discount;
  }
  unsigned int min_discount = size;
  for(i=0;i<M;i++)
  {
  	min_discount = min(min_discount,discounts[i]);
  }
  cout<<min_discount;

}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,m;
    cin>>a>>b>>m;
    int arr[a+1];
    int brr[b+1];
    for(int i=1;i<=a;i++)
    {
        cin>>arr[i];
    }
    for(int i=1;i<=b;i++)
    {
        cin>>brr[i];
    }
    int ans = 2*(1e6);
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            ans=min(ans,arr[i]+brr[j]);
        }
    }
    while(m--)
    {
        int x,y,c;
        cin>>x>>y>>c;
        ans = min(ans,arr[x]+brr[y]-c);

    }
    cout<<ans<<"\n";
    
}
//  [c]
#define rep(i,n)for(int i=0;i<n;i++)
#define mi(x,y) (x<y?x:y)
#define N 100003//overflow防止
int main(){
	int A,B,M,a[N],am=1e5,b[N],bm=1e5,x,y,c,cm=2e5;
	scanf("%d%d%d",&A,&B,&M);
	rep(i,A){scanf("%d",&a[i+1]);am=mi(am,a[i+1]);}
	rep(i,B){scanf("%d",&b[i+1]);bm=mi(bm,b[i+1]);}
	rep(i,M){
		scanf("%d%d%d",&x,&y,&c);
		cm=mi(cm,a[x]+b[y]-c);
	}
	printf("%d",mi(cm,am+bm));
}
//  [c]
int main(){
  int A,B,M,c,x,y;
  int a[100000],b[100000];
  int i,min,sum,mina,minb;
  scanf("%d %d %d",&A,&B,&M);
  for(i=0;i<A;i++){
    scanf("%d",&a[i]);
    if(i==0 || a[i]<mina) mina=a[i];
  }
  for(i=0;i<B;i++){
    scanf("%d",&b[i]);
    if(i==0 || b[i]<minb) minb=b[i];
  }
  min=mina+minb;
  for(i=0;i<M;i++){
    scanf("%d %d %d",&x,&y,&c);
    sum=a[x-1]+b[y-1]-c;
    if(sum<min) min=sum;
  }
  printf("%d",min);
  return 0;
}
//  [c]
#include <stdio.h>

int main(){
    unsigned long A,B,M;
    unsigned long a[100000], b[100000], mina, minb,inda,indb,mindata;

    unsigned long x, y, c;
    int i, j, k;

    scanf("%ld %ld %ld", &A, &B, &M);
    for (i = 0; i < A;i++){
        scanf("%ld", &a[i]);
        if(i == 0){
            mina = a[i];
            inda = i;
        }else{
            if (mina > a[i])
            {
                mina = a[i];
                inda = i;
            } 
        }
    }
    for (i = 0; i < B; i++)
    {
        scanf("%ld", &b[i]);
        if(i == 0){
            minb = b[i];
            indb = i;
        }
        else
        {
            if (minb > b[i])
            {
                minb = b[i];
                indb = i;
            }
        }

    }

    mindata = mina + minb;
    for (i = 0; i < M; i++)
    {
        scanf("%ld %ld %ld", &x, &y, &c);

        if(mindata > (a[x-1] + b[y-1] - c)){
            mindata = (a[x-1] + b[y-1] - c);
        }
    }

    printf("%ld", mindata);

    return 0;
}
//  [c]
#include <stdio.h>
int main(void){
    int A, B, M;
    int a[10000+5], b[10000+5];
    int x[10000+5], y[10000+5], c[10000+5];
    
    scanf("%d %d %d", &A, &B, &M);
    for(int i=1; i<=A; i++)scanf("%d", &a[i]);
    for(int i=1; i<=B; i++)scanf("%d", &b[i]);
    for(int i=0; i<M; i++)scanf("%d %d %d", &x[i], &y[i], &c[i]);
    
    int ans=0;
    
    // 割引券無し
    int min=a[1];
    for(int i=1; i<A; i++)if(a[i]<min)min=a[i];
    ans+=min;
    
    min=b[1];
    for(int i=1; i<B; i++)if(b[i]<min)min=b[i];
    ans+=min;
    
    // 割引券
    for(int i=0; i<M; i++){
        if(a[x[i]]+b[y[i]]-c[i]<ans)ans=a[x[i]]+b[y[i]]-c[i];
    }
    printf("%d\n", ans);
    return 0;
}
//  [c]
#include<stdio.h>
int main()
{
int a,b,m,i,minf,minr,ans;
  minf=10*10*10*10*10;
  minr=10*10*10*10*10;
  scanf("%d %d %d",&a,&b,&m);
  
int frz[a],range[b],x[m],y[m],c[m];
  
  for(i=0;i<a;++i)
  {
   scanf("%d",&frz[i]);
   if(minf>frz[i])  minf=frz[i];
  }
  
  for(i=0;i<b;++i)
  {
   scanf("%d",&range[i]);
   if(minr>range[i])  minf=range[i];
  }
  
ans=minf+minr;
  
  for(i=0;i<m;++i)
  {
  scanf("%d %d %d",&x[i],&y[i],&c[i]);
  if(frz[x[i]-1] + range[y[i]-1] -c[i] < ans) ans=frz[x[i]-1] + range[y[i]-1] -c[i];
  }

printf("%d",ans);
return 0;
}
//  [c]
#include<stdio.h>
int main()
{
int a,b,m,i,minf,minr,ans;
  minf=10*10*10*10*10;
  minr=10*10*10*10*10;
  scanf("%d %d %d",&a,&b,&m);
  
int frz[a],range[b],x[m],y[m],c[m];
  
  for(i=0;i<a;++i)
  {
   scanf("%d %d",&frz[i],&range[i]);
   if(minf>frz[i])  minf=frz[i];
   if(minr>range[i]) minr=range[i];
  }
ans=minf+minr;
  
  for(i=0;i<m;++i)
  {
  scanf("%d %d %d",&x[i],&y[i],&c[i]);
  if(frz[x[i]-1] + range[y[i]-1] -c[i] < ans) ans=frz[x[i]-1] + range[y[i]-1] -c[i];
  }

printf("%d",ans);
return 0;
}
//  [javascript]
const main = (inputs) => {
  const array = inputs[0].split(' ');
  const A = array[0];
  const B = array[1];
  const M = Number(array[2]);

  const array_A = inputs[1].split(' ');
  const array_B = inputs[2].split(' ');
  var answer = 0;


  const minPrice_A = Math.min.apply(null, array_A);
  const minPrice_B = Math.min.apply(null, array_B);

  for (var i = 3; i < 3 + M; i++) {
    var array_M = inputs[i].split(' ');
    var price = Number(array_A[array_M[0] - 1]) + Number(array_B[array_M[1] - 1]) - Number(array_M[2]);
    if (i === 3 || price < answer) {
      answer = price;
    }
  }
  answer = answer < minPrice_A + minPrice_B ? answer : minPrice_A + minPrice_B;
  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));