jiahuimbzuai/CoQuIR huggingface dataset:
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

if N % 2 == 0
  puts N
else
  puts N * 2
end
//  [rust]
use std::io::Read;

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

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    if n % 2 == 0 {
        return n.to_string();
    }

    return (n * 2).to_string();
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    }
    println!("{}",if a%2==0 {a }else{a*2})
}
//  [rust]
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		n: usize,
	}

	if n % 2 == 0 {
		println!("{}", n);
	}
	else {
		println!("{}", n*2);
	}
}
//  [swift]
import Foundation

let number : Int = Int(readLine(stripNewline: true)!)!

if number % 2 == 0 {
  print("\(number)")
} else {
  print("\(number * 2)")
}
//  [typescript]
import { readFileSync } from "fs";

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

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

  return N % 2 === 0 ? N : N * 2;
};

console.log(main(read()));
//  [typescript]
process.stdin.setEncoding('utf8');

process.stdin.on("data", function(d) {
    let n = +d;
    if (n%2 == 1) {
        console.log(2*n);
    } else {
        console.log(n);
    }
})
//  [typescript]
process.stdin.setEncoding('utf8');

process.stdin.on("data", function (d) {
    let n = +d;
    if (n % 2 == 1) {
        console.log(2 * n);
    } else {
        console.log(n);
    }
})
//  [python]
import sys
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
lineA = lines.pop(0).split(' ')
lineB = lines.pop(0).split(' ')

minP = int(min(lineA)) + int(min(lineB))
#print(minP)

A = int(line1[0])
#print(A)
B = int(line1[1])
#print(B)
M = int(line1[2])
#print(M)

for i in range(M):
  line = lines.pop(0).split(' ')
  ax = int(line[0])
  bx = int(line[1])
  cx = int(line[2]) if len(line) == 3 else 0
  #print(ax)
  #print(bx)
  #print(cx)
  price = int(lineA[ax-1]) + int(lineB[bx-1]) - cx
  #print(price)
  if minP > price:
    minP = price

print(minP)
//  [python]
import numpy as np
import collections

A,B,M = map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))


answer=0
x=[]
y=[]
c=[]

answer = min(a)+min(b)

for i in range(M):
    x1,y1,c1 = map(int,input().split())
    if a[x1-1]+b[y1-1]-c1 < answer:
        answer = a[x1-1]+b[y1-1]-c1

#for x in c.values():
#    answer +=x*(x-1) // 2

print(answer)
//  [python]
import numpy as np

a, b, m = map(int, input().split())

an = np.asarray(input().split(), dtype=np.uint32)

bn = np.asarray(input().split(), dtype=np.uint32)

minimum = np.min(an) + np.min(bn)

for i in range(m):
    x, y, c = map(int, input().split())
    new_value = an[x-1] + bn[y-1] - c
    if minimum > new_value:
        minimum = new_value

print(minimum)
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        String ans = "";

        int[] abm = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] an = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] bn = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int cheapestAn = 999999;
        for(int i=0; i<an.length; i++) {
            if (an[i] < cheapestAn) cheapestAn = an[i];
        }
        int cheapestBn = 999999;
        for(int i=0; i<bn.length; i++) {
            if (bn[i] < cheapestBn) cheapestBn = bn[i];
        }
        int mostCheap = cheapestAn + cheapestBn;

        for (int i = 0; i < abm[2]; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();
            int usedCoupon = an[x - 1] + bn[y - 1] - c;
            if (usedCoupon < mostCheap) {
                mostCheap = usedCoupon;
            }
        }
        System.out.println(mostCheap);
    }
}
//  [java]
import java.util.*;

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

class Item implements Comparable<Item> {
    int cost;
    int index;

    public Item(int cost, int index) {
        this.cost = cost;
        this.index = index;
    }

    @Override
    public int compareTo(Item other) {
        return Integer.compare(this.cost, other.cost);
    }

}

class Solver {

    private String buildKey(int x, int y) {
        StringBuilder sb = new StringBuilder();
        sb.append(x);
        sb.append(",");
        sb.append(y);
        return sb.toString();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();

        List<Item> a = new ArrayList<>();
        for (int i = 0; i < A; i++) {
            a.add(new Item(sc.nextInt(), i));
        }
        List<Item> as = new ArrayList<>(a);
        Collections.sort(as);

        ArrayList<Item> b = new ArrayList<>();
        for (int i = 0; i < B; i++) {
            b.add(new Item(sc.nextInt(), i));
        }
        ArrayList<Item> bs = new ArrayList<>(b);
        Collections.sort(bs);

        Map<String, Integer> m = new HashMap<String, Integer>();
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();
           String key = buildKey(x, y);
            if (m.containsKey(key)) {
                int v = m.get(key);
                m.put(key, Math.max(v, c));
            } else {
                m.put(key, c);
            }
        }


        int minCost = as.get(0).cost + bs.get(0).cost;
        String minKey = buildKey(as.get(0).index, bs.get(0).index);
        if (m.containsKey(minKey)) {
            minCost = as.get(0).cost + bs.get(0).cost  - m.get(minKey);
        }

        for (Map.Entry e : m.entrySet()) {
            String k = (String) e.getKey();
            if (m.containsKey(k)) {
                String[] keys = k.split(",");
                int key1 = Integer.parseInt(keys[0]);
                int key2 = Integer.parseInt(keys[1]);
                int c1 = a.get(key1 - 1).cost;
                int c2 = b.get(key2 - 1).cost;
                minCost = Math.min(c1 + c2 - m.get(k), minCost);
            }
        }
        System.out.println(minCost);
        

        return;
    }

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); // 冷蔵庫
		int b = sc.nextInt(); // 電子レンジ
		int c = sc.nextInt(); // 割引券
		Integer d[] = new Integer[a];
		Integer e[] = new Integer[b];
		int f = 0;

		for (int i = 0; i < a; i++) {
			d[i] = sc.nextInt();
		}
		for (int i = 0; i < b; i++) {
			e[i] = sc.nextInt();
		}
		for (int i = 0; i < c; i++) {
			int l = sc.nextInt() - 1;
			int m = sc.nextInt() - 1;
			int n = sc.nextInt();
			if (i > 0) {
				f = Integer.sum(d[l], e[m]) - n > f ? f
						: Integer.sum(d[l], e[m]) - n;
			} else {
				f = Integer.sum(d[l], e[m]) - n;
			}
		}

		Arrays.sort(d);
		Arrays.sort(e);
		int h = d[0] + e[0];

		System.out.println(f > h ? h : f);

	}
}
//  [cpp]
#include <iostream>
#include <stdio.h>

#define MAX_A 100'000

using namespace std;

int A[MAX_A];
int B[MAX_A];

int main() {
  int NA, NB, M;
  cin >> NA >> NB >> M;
  for (int i = 0; i < NA; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < NB; ++i) {
    cin >> B[i];
  }

  int res = 2 * MAX_A + 1;
  for (int i = 0; i < M; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    res = min(A[x - 1] + B[y - 1] - c, res);
  }
  for (int i = 0; i < NA; ++i) {
    for (int j = 0; j < NB; ++j) {
      res = min(A[i] + B[j], res);
    }
  }
  printf("%d\n", res);
}
//  [cpp]
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int a,b,m;
  cin >> a >> b >> m;
  vi p(a);
  vi q(b);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  vi sum(m+1);
  rep(i,m){
    int aa,bb,cc;
    cin >> aa >> bb >> cc;
    aa--;
    bb--;
    sum[i] = p[aa]+q[bb]-cc;
  }
  
  
  
  
  
  sort(ALL(p));
  sort(ALL(q));
  sum[m] = p[0] + q[0];
  sort(ALL(sum));
  cout << sum[0] << endl;
  
  
}
//  [cpp]
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a,b,m; cin >> a >> b >> m;
  vl an(a); vl bn(b);
  rep(i,a){ ll x; cin >> x; an[i] = x; }
  rep(i,b){ ll x; cin >> x; bn[i] = x; }
  
  ll lowcost = 100000000;
  for(ll i=0; i < m; i++){
    ll x,y,c; cin >> x >> y >> c;
    lowcost = min(lowcost,an[x-1]+bn[y-1]-c);
  }
  
  sort(all(an)); sort(all(bn));
  
  lowcost = min(lowcost,an[0]+bn[0]);
  
  cout << lowcost << endl;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
typedef struct{
    int x,y,c;
}list;
int str_comp(const void*a,const void*b){return ((list*)b)->c-((list*)a)->c;}
int int_comp(const void*a,const void*b){return *(int*)a-*(int*)b;}
void yes(){printf("Yes\n");}
void no(){printf("No\n");}

int main(void)
{
    int a,b,m;
    int aa[100000],bb[100000];
    list xyc[100000];


    scanf("%d %d %d",&a,&b,&m);
    for(int i=0;i<a;i++){
        scanf("%d",&aa[i]);
    }
    for(int i=0;i<b;i++){
        scanf("%d",&bb[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d %d %d",&xyc[i].x,&xyc[i].y,&xyc[i].c);
    }
    qsort(xyc,m,sizeof(list),str_comp);
    int min1=INT_MAX,mini=0;
    for(int i=0;i<m;i++){
        int tmp=aa[xyc[i].x-1]+bb[xyc[i].y-1]-xyc[i].c;
        if(min1>tmp){
            min1=tmp;
        }
    }
    qsort(aa,a,sizeof(int),int_comp);
    qsort(bb,b,sizeof(int),int_comp);
    int min2=aa[0]+bb[0];
    if(min1>min2)printf("%d\n",min2);
    else printf("%d\n",min1);

    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b,c;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}

#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int A,B,M;
    scanf("%d%d%d",&A,&B,&M);
    int ref[A];
    int wav[B];
    data sale[M];
    rep(i,A){
        scanf("%d",&ref[i]);
    }
    rep(i,B){
        scanf("%d",&wav[i]);
    }
    rep(i,M){
        scanf("%d%d%d",&sale[i].a,&sale[i].b,&sale[i].c);
    }
    int fct[M+1];
    rep(i,M){
        fct[i]=ref[sale[i].a-1]+wav[sale[i].b-1]-sale[i].c;
    }
    qsort(ref,A,sizeof(int),compare_int);
    qsort(wav,B,sizeof(int),compare_int);
    fct[M]=(ref[0]+wav[0]);
    qsort(fct,M+1,sizeof(int),compare_int);
    printf("%d",fct[0]);
}
//  [javascript]
function Main (input) {
  input = input.split("\n").map(inp => inp.split(" ").map(inp2 => parseInt(inp2, 10)));
  var A = input[0][0];
  var B = input[0][1];
  var M = input[0][2];
  var a = input[1];
  var b = input[2];
  input.shift();
  input.shift();
  input.shift();
  input.pop();
  var x = input;
  var kh = [];
  
  for (var i of x) {
    kh.unshift((a[i[0]-1]+b[i[1]-1]) - i[2]);
  }
  console.log(Math.min(...a) + Math.min(...b) < Math.min(...kh) ? Math.min(...a) + Math.min(...b) : Math.min(...kh))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[0]);
    
    const freezer = arg[1].split(" ").map(n=>parseInt(n));
    const renzi   = arg[2].split(" ").map(n=>parseInt(n));
    
    const xyc = arg.slice(3, M + 4);
    
    const minFreeze = Math.min(...freezer);
    const minRenzi = Math.min(...renzi);
    
    let temp = minFreeze + minRenzi;
    
    for(let i in xyc) {
        let x = parseInt(xyc[i].split(" ")[0]);
        let y = parseInt(xyc[i].split(" ")[1]);
        let c = parseInt(xyc[i].split(" ")[2]);
        
        let cost = freezer[x-1] + renzi[y-1] - c;
        
        if(cost <= temp) {
            temp = cost;
        }
    }
    
    console.log(temp);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b, m int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &m)

	as := make([]int, a)
	minA := math.MaxInt64
	for i := 0; i < a; i++ {
		fmt.Fscan(r, &as[i])
		minA = min(minA, as[i])
	}
	bs := make([]int, b)
	minB := math.MaxInt64
	for i := 0; i < b; i++ {
		fmt.Fscan(r, &bs[i])
		minB = min(minB, bs[i])
	}

	var x, y, c int
	ans := minA + minB
	for i := 0; i < m; i++ {
		fmt.Fscan(r, &x)
		fmt.Fscan(r, &y)
		fmt.Fscan(r, &c)
		x--
		y--

		sum := as[x] + bs[y] - c
		ans = min(ans, sum)
	}

	fmt.Println(ans)
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
//  [go]
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var a, b, m int
	fmt.Scanf("%d %d %d", &a, &b, &m)

	av := make([]int, a)
	bv := make([]int, b)

	N := 200000
	amin, bmin := N, N
	for i := 0; i < a; i++ {
		fmt.Fscan(r, &av[i])
		if amin > av[i] {
			amin = av[i]
		}
	}
	for i := 0; i < b; i++ {
		fmt.Fscan(r, &bv[i])
		if bmin > bv[i] {
			bmin = bv[i]
		}
	}

	res := amin + bmin
	for i := 0; i < m; i++ {
		var x, y, c int
		fmt.Fscan(r, &x, &y, &c)

		t := av[x - 1] + bv[y - 1] - c
		if t < res {
			res = t
		}
	}

	fmt.Println(res)
}
//  [go]
package main

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

func main() {
	A, B, M := ReadInt(), ReadInt(), ReadInt()
	a := ReadInts(A)
	b := ReadInts(B)
	ans := Min(a...) + Min(b...)
	for i := 0; i < M; i++ {
		x, y, c := ReadInt()-1, ReadInt()-1, ReadInt()
		v := a[x] + b[y] - c
		ans = Min(ans, v)
	}
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [ruby]
# Wrote in Mar 8, 2020 21:42 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n)
  t = [[],[],[]]
  n.times do |i|
    t[0][i],t[1][i],t[2][i] = inp
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end
#---------------

A,B,M = inp
a = inp
b = inp
x,y,c = minp(M)

results = []

[*1..M].each do |n|
  results.push(a[x[n-1]-1]+b[y[n-1]-1]-c[n-1])
end

[*1..([A,B].min)].each do |n|
  results.push(a[n-1]+b[n-1])
end

results.push(a.min+b.min)

puts results.min
//  [ruby]
A, B, M = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

x = []
y = []
c = []

M.times do
  line = gets.chop.split.map(&:to_i)
  x << line.shift
  y << line.shift
  c << line.shift
end

price = a.min + b.min

discount = []

M.times do |i|
  X = x[i] - 1
  Y = y[i] - 1
  d = a[X] + b[Y] - c[i]
  discount << d
end

waribiki = discount.min

puts [price, waribiki].min
//  [ruby]
a,b,m = gets.chomp.split(/ /).map(&:to_i)
as = gets.chomp.split(/ /).map(&:to_i)
bs = gets.chomp.split(/ /).map(&:to_i)
min = as.min + bs.min

m.times do
    x,y,c = gets.chomp.split(/ /).map(&:to_i)
    price = as[x - 1] + bs[y - 1] - c
    min = price if min > price
end
puts min
//  [rust]
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let m: usize = read();

    let mut aa: Vec<usize> = (0..a).map(|_| read()).collect();
    let mut bb: Vec<usize> = (0..b).map(|_| read()).collect();
    let xyc: Vec<(usize, usize, usize)> = (0..m).map(|_| (read(), read(), read())).collect();

    let ans: usize = xyc
        .iter()
        .map(|&(x, y, c)| aa[x - 1] + bb[y - 1] - c)
        .min()
        .unwrap();

    aa.sort();
    bb.sort();

    println!("{}", std::cmp::min(ans, aa[0] + bb[0]));
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
//  [rust]
fn main() {
    let (a, b, m): (usize, usize, usize) = (read(), read(), read());
    // let mut discp: HashMap<(usize, usize), usize> = HashMap::new();
    let mut av: Vec<usize> = vec![];
    let mut bv: Vec<usize> = vec![];
    for _ in 0..a {
        av.push(read());
    }
    for _ in 0..b {
        bv.push(read());
    }
    let mut ans = std::usize::MAX;
    for _ in 0..m {
        let (r, d, k): (usize, usize, usize) = (read(), read(), read());
        ans = min(av[r - 1] + bv[d - 1] - k, ans);
    }
    av.sort();
    bv.sort();
    println!("{:?}", min(av[0] + bv[0], ans));
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::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")
}

// =========
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.hitachi2020 {

    export class Program {
        /**
         * in
         * 2 2 1
         * 3 5
         * 3 5
         * 2 2 2
         * out
         * 6
         */
        static main(inp: string): void {

            // a,bの最安値
            // クーポンを使ったときの値
            const [a, b, m]: number[] = inp.split('\n')[0].split(' ').map(Number);
            const aList: number[] = inp.split('\n')[1].split(' ').map(Number);
            const bList: number[] = inp.split('\n')[2].split(' ').map(Number);

            let ans1: number = 0;
            // ans1 = aList.sort()[0];
            // ans1 += bList.sort()[0];
            // ans1 = Math.min(...aList)
            // ans1 += Math.min(...bList)
            ans1 = aList.reduce((a, b) => Math.min(a, b));
            ans1 += bList.reduce((a, b) => Math.min(a, b));

            // クーポン
            const ww: string[] = inp.split('\n');
            for (let i: number = 0; i < m; i++) {
                const [x, y, c]: number[] = ww[i + 3].split(' ').map(Number);

                let wk: number = aList[x - 1] + bList[y - 1] - c;
                if (ans1 > wk) {
                    ans1 = wk;
                }
            }

            console.log(ans1);

        }
    }
}

AtCoder.hitachi2020.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
//  [typescript]
function Main(input) {
    const lines = input.split("\n");

    const [A, B, M] = lines.shift().split(' ').map(Number);
    const aList = lines.shift().split(' ').map(Number);
    const bList = lines.shift().split(' ').map(Number);

    const minA = aList.reduce((acc, current) => Math.min(acc, current));
    const minB = bList.reduce((acc, current) => Math.min(acc, current));

    let minCost = minA + minB;

    for (let i = 0; i < M; i++) {
        const [x, y, c] = lines[i].split(' ').map(Number);
        minCost = Math.min(minCost, aList[x-1] + bList[y-1] - c);
    }

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [A, B, M] = r.nn()

    const ap = r.nn()
    const bp = r.nn()

    const amin = ap.reduce((a, b) => Math.min(a, b), Infinity)
    const bmin = bp.reduce((a, b) => Math.min(a, b), Infinity)

    let res = amin + bmin

    for (let i = 0; i < M; i++) {
      const [x, y, c] = r.nn()

      res = Math.min(res, ap[x - 1] + bp[y - 1] - c)
    }

    return res
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map(line => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}
//  [python]
import numpy as np
n, x = map(int, input().split())
ls = []
count = 1
pos = 0
for l in map(int, input().split()):
    pos += l
    if (pos) > x:
        break
    else:
        count += 1
print(count)
//  [python]
import numpy as np
N, X = map(int, input().split())
l_list = np.array(input().split()).astype(int)


cumsum = np.cumsum(l_list)
print((cumsum <= X).sum()+1)
//  [python]
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N, X = [int(x) for x in stdin.readline().rstrip().split()]
L = [int(x) for x in stdin.readline().rstrip().split()]
cnt = 1
n = 0
for l in L:
  n += l
  if n>X:
    break
  cnt += 1
print(cnt)
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int X = s.nextInt();
			final int[] L = IntStream.generate(s::nextInt).limit(N).toArray();

			boolean fin = false;
			int d = 0;
			for (int i = 0; i < N; i++) {
				d += L[i];
				if (d > X) {
					System.out.println(i + 1);
					fin = true;
					break;
				}
			}
			if (!fin) {
				System.out.println(N + 1);
			}
		}
	}
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);

        final int n = scanner.nextInt();
        final int x = scanner.nextInt();
        scanner.nextLine();
        final int[] l = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        final int[] hops = new int[n + 1];
        hops[0] = 0;
        for (int i = 1; i < n + 1; i++) {
            hops[i] = hops[i - 1] + l[i - 1];
        }

        int count = 0;
        for (int i = 0; i < n + 1; i++) {
            if (x < hops[i]) break;

            count++;
        }

        System.out.println(count);
    }
}
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            int X = Integer.valueOf(args.get(0).split(" ")[1]);
            List<Integer> numList = Arrays.stream(args.get(1).split(" ")).map(Integer::valueOf).collect(Collectors.toList());
            int ans = 1;
            int acm = 0;
            for (int num: numList) {
                acm += num;
                if (acm <= X) ans++;
            }
            System.out.println(ans);
        };
    }

}
//  [cpp]
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, X;
    cin >> N >> X;
    int L[N];
    Fp(i, 0, N) cin >> L[i];
    int i = 2, sum = 0;
    while((sum += L[i - 2]) <= X && i <= N + 1){
        i++;
    }
    cout << i - 1 << endl;
}
//  [cpp]
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}


int main()
{
	int n, x;
	cin >> n >> x;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		sum += tmp;
		if (sum > x)
		{
			cout << (i + 1);
			return 0;
		}
	}
	cout << (n + 1);
}
//  [c]
#include <stdio.h>
int main(void){
    int n,x,g=0,c=1,l[100];
    
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)scanf("%d",&l[i]);
    for(int i=0;i<n;i++){
        g+=l[i];
        if(g>x)break;
        c++;
    }
    printf("%d",c);
    
  return 0;
}
//  [c]
#include <stdio.h>
int main(void){
    int n,x,g=0,i,l[100];
    
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)scanf("%d",&l[i]);
    for(i=0;i<n;i++){
        g+=l[i];
        if(g>x)break;
    }
    printf("%d",i+1);
    
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int n, x, l, d=0, count=1;
  scanf("%d %d",&n,&x);
  for (int i = 1;i < n+1 ;i++) {
    scanf("%d",&l);
    d += l;
    if (d > x) {
      break;
    }
    count++;
  }
  printf("%d",count);  
}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var l = o.l();
  var ans = 1;
  var t = 0;
  for(var i = 0; i < n; i++){
    t += l[i];
    if(t > x)break;
    ans++;
  }
  return ans;
}
//  [javascript]
'use strict';
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  let inputs = input.split("\n");
  let tmp1 = inputs[0].split(" ");
  let l = inputs[1].split(" ");
  //文字列から10進数に変換するときはparseIntを使います
  let n = parseInt(tmp1[0], 10);
  let x = parseInt(tmp1[1], 10);

  let d = [];
  d.push(0);

  l.map(elm => parseInt(elm, 10))
    .forEach((elm, i) => {
    d[i + 1] = d[i] + elm;
  });

  if (d.findIndex(isLargeNumber) === -1) {
    console.log(d.length);
  } else {
    console.log(d.findIndex(isLargeNumber));
  }

  function isLargeNumber(element) {
    return element > x;
  }

  //出力
  // console.log('%d %s', b, c);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
)

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

const (
	MOD = 998244353
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N, X int
	fmt.Scanf("%d %d\n", &N, &X)
	L := make([]int, N)
	for i := 0; i < N; i++ {
		var l int
		fmt.Scan(&l)
		L[i] = l
	}
	cnt := 0
	if X >= 0 {
		cnt++
	}
	var last int
	for i := 0; i < N; i++ {
		last = last + L[i]
		if last <= X {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}
//  [go]
package main

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

func main() {
	N, X := ReadInt(), ReadInt()
	cnt := 1
	v := 0
	for i := 0; i < N; i++ {
		v += ReadInt()
		if v <= X {
			cnt++
		} else {
			break
		}
	}
	fmt.Println(cnt)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
//  [go]
package main

import (
	"fmt"
)

func main() {

	var N, X int
	fmt.Scanf("%d %d", &N, &X)

	L := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &L[i])
	}

	var count int = 1
	D := make([]int, N+1)
	D[1] = 0
	for i := 1; i < N+1; i++ {
		D[i] = D[i-1] + L[i-1]
		if X < D[i] {
			break
		}
		count++
	}

	fmt.Println(count)
}
//  [ruby]
n,t,*l=`dd`.split.map &:to_i
p [0,*l].count{0<=t-=_1}
//  [ruby]
n,x = gets.chomp.split(' ').map(&:to_i)
l = gets.chomp.split(' ').map(&:to_i)
current = 0
count = 0
l.each do |num|
  if (current <= x)
    count += 1
  end
  current += num
end
if (current <= x)
  count += 1
end
puts count
//  [ruby]
n, x = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
cnt = 1
sum = 0
arr.each do |a|
	sum += a
	if sum > x 
		puts cnt 
		exit 
	end
	cnt += 1
end
puts cnt
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    mut c:[usize;a],
    }
    let mut s:usize=1;
    let mut sum:usize=0;
    for i in 0..a {
        sum+=c[i];
        if sum<=b {s+=1;}
    }
    println!("{}",s)
}
//  [rust]
#[allow(unused_imports)]
use std::io::Write;

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![N: usize, X: usize, L: [usize; N]];
    let mut ans = 1;
    let mut sum = 0;
    for l in L {
        sum += l;
        if sum <= X {
            ans += 1;
        }
    }
    println!("{}", ans);
}
//  [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 read_n<T: FromStr>(n: usize) -> Vec<T> {
    let mut a: Vec<T> = vec![];
    for _ in 0..n {
        a.push(read());
    }
    a
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let x: i64 = read();

    let l: Vec<i64> = read_n(n);
    // println!("l:{:?}", l);

    let mut sum = 0;
    let mut cnt = 1;

    for i in l {
        sum += i;
        if sum <= x {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}
//  [swift]
import Foundation
 
let input_line = readLine()!
 
let split = input_line.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
let N = Int(split[0])!
let X = Int(split[1])!
 
var Li = [Int]()
let input_line2 = readLine()!

for i in 0..<N {
    let splits = input_line2.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
	Li = splits.map {Int($0)!}
}

var counter = 1
var boundPosition = 0

for j in 0..<N {
    boundPosition += Li[j]
    if X < boundPosition {
        break
    }
    counter += 1
}

print(counter)
//  [swift]
import Foundation
import CoreFoundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    func reversed() -> Array {
        return self.reverse()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // 2つの条件に優先順位をつけてソート

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, X) = (input[0], input[1])
let L = readIntSplit(by: " ")
var D = 0
var ans = 1
for i in L {
    D += i
    if D <= X {
        ans += 1
    }
}
print(ans)
//  [swift]
let arr1=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let n = arr1[0]
let x = arr1[1]

let arr2=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var i = 0
var j = 0
var o = 0

while(  i <= x ){
  if( o >= n ) {
    o += 1 
    break
  }
  i += arr2[o]
  o += 1
}

print( o )
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, x] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)
const l = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  b = [0]
  for (let i = 1; i < n + 1; i++) {
    const bounce = b[i - 1] + l[i - 1]

    b.push(bounce)
  }

  return b.filter(e => x >= e).length
}

console.log(ans())
//  [typescript]
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, X: number, L: number[] } => {
  const [N, X] = lines[0].split(' ').map(line => +line)
  const L = lines[1].split(' ').map(line => +line)
  const obj = { N, X, L }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N, X, L } = parseLines(lines)

  const bounds = [0]
  for (let i = 1; i < N + 1; i++) {
    const d = bounds[i-1] + L[i-1]
    bounds.push(d)
  }
  const count = bounds.filter(b => b <= X).length
  return `${count}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [typescript]
// AtCoder Beginner Contest 130
// https://atcoder.jp/contests/abc130
import * as fs from "fs";

const stdin = fs.readFileSync("/dev/stdin", "utf8");
const split = stdin.split("\n");
Main(split);

function Main(inputLines: string[]) {
  const tmp = inputLines[0].split(" ");
  const N = Number(tmp[0]);
  const X = Number(tmp[1]);
  const input = inputLines[1].split(" ").map(ele=>Number(ele));
  Sub(N, X, input);
}
function Sub(N: number, X: number, input: number[]) {
  let point = 0;
  let count = point <= X ? 1 : 0;
  for (const l of input) {
    point += l;
    if (point <= X) {
      count += 1;
    }
  }
  console.log(count);
}
//  [python]
input();print(sum([bin(i)[::-1].index("1") for i in map(int,input().split())]))
//  [python]
def connt_half(n):
    return (n ^ (n - 1)).bit_length() - 1

# 入力
n = int(input())
a = list(map(int, input().split()))


ans = 0
for v in a:
    ans += connt_half(v)
# 出力
print(ans)
//  [python]
input();print(sum([bin(i)[::-1].index('1')for i in map(int,input().split())]))
//  [python]
N=int(input())
a=map(int,input().split())
a=list(a) 
import numpy as np
count_list=[0]*N
def gcd(a,b):
    c=np.floor(a/b)
    return a-b*c
for i in range(len(a)):
    while gcd(a[i],2)==0:
        count_list[i]+=1
        a[i]=a[i]/2

print(sum(count_list))
//  [python]
N = int(input())
A = list(map(int, input().split()))
pi_A = 1

for a in A:
    pi_A *= a

cnt = 0
while pi_A % 2 == 0:
    pi_A = pi_A // 2
    cnt += 1

print(cnt)
//  [python]
n = int(input())
a = input().split()
aa = [int(a[i]) for i in range(n)]
b = 1
for i in range(n):
  s = list(str(aa[i]))
  ss = int(s[-1])
  if ss == 0 or ss == 2 or ss == 4 or ss == 6 or ss == 8:
  	b = b * aa[i]

c = 0
cnt = 0
while c < 1:
  if b % 2 == 0:
    b = b // 2
    cnt = cnt + 1
  else:
    c = 1
print(cnt)